Skip to content

Commit

Permalink
added arguments to N mean and N median position by updatign give.n ut…
Browse files Browse the repository at this point in the history
…ility function in global based on recent projects

continue to work on the ER functions
  • Loading branch information
certara-smouksassi committed Aug 21, 2024
1 parent a621d8e commit 3362ff0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ggquickeda 0.3.1.9000

* added to possible positions on where to put the N of observations in Mean and Median tabs: (fixed, mean, median)
* added arguments `show.exptile_values`, `show.exptile_values_pos` and `show.exptile_values_order` to
`ggkmrisktable()` requested by Mathilde
* fixes for `gglogisticexpdist()` and `ggcontinuousexpdist()` when `exposure_distribution`and `exposure_metric_split` where set to "none"
Expand Down
22 changes: 16 additions & 6 deletions inst/shinyapp/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,27 @@ mean.n <- function(x, nroundlabel = 2, labeltrans =c("none","exp") ){
return(c(y = meanxvalue, label = meanxlabel ))
}

give.n <- function(x, nposition = c("min","max","below","up"),

give.n <- function(x,
nposition = c("min","max","below","up","fixed","mean","median"),
mult = 1, add = 0
){
if ( nposition == "below"){
if (nposition == "min"){
yposition <- min(x)*mult + add
} else if (nposition == "max") {
yposition <- max(x)*mult + add
} else if (nposition == "below") {
yposition <- -Inf
} else if (nposition == "up") {
yposition <- Inf
} else if (nposition == "min"){
yposition <- min(x)*mult + add
} else
yposition <- max(x)*mult + add
} else if (nposition == "fixed") {
yposition <- add
} else if (nposition == "mean") {
yposition <- mean(x, na.rm = TRUE)*mult + add
} else if (nposition == "median") {
yposition <- median(x, na.rm = TRUE)*mult + add
}
else yposition <- 0
return(c(y = yposition, label = length(x)))
}

Expand Down
10 changes: 8 additions & 2 deletions inst/shinyapp/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,10 @@ function(request) {
radioButtons("mean_N_position", "N Positioning:",
c("min" = "min","max" = "max",
"lower/left edge" = "below",
"upper/right edge" = "up"
"upper/right edge" = "up",
"at add adj value" = "fixed",
"at mean value" ="mean",
"at median value" ="median"
), inline = TRUE),
numericInput("mean_N_add",label = "N Additive adjustment",
value = 0, min = NA, max = NA, step = 0.1),
Expand Down Expand Up @@ -2135,7 +2138,10 @@ function(request) {
radioButtons("median_N_position", "N Positioning:",
c("min" = "min","max" = "max",
"lower/left edge" = "below",
"upper/right edge" = "up"
"upper/right edge" = "up",
"at add adj value" = "fixed",
"at mean value" ="mean",
"at median value" ="median"
), inline = TRUE),
numericInput("median_N_add",label = "N Additive adjustment",
value = 0, min = NA, max = NA, step = 0.1),
Expand Down

0 comments on commit 3362ff0

Please sign in to comment.