diff --git a/boxplot_stat_function.R b/boxplot_stat_function.R index 2ad5a07..92f6c0d 100755 --- a/boxplot_stat_function.R +++ b/boxplot_stat_function.R @@ -23,8 +23,12 @@ getwd() is.error <- function(x) inherits(x, "try-error") -doMyPlotsStats <- function(df) { - mediators = levels(as.factor(df$mediator)) +doMyPlotsStats <- function(df, custom_order=NULL) { + if(!is.null(custom_order)){ + mediators = custom_order + } else{ + mediators = levels(as.factor(df$mediator)) + } plots <- list() @@ -44,7 +48,7 @@ doMyPlotsStats <- function(df) { #, palette = c("#00BFC4", "#F8766D") ))+ scale_colour_manual(values=c("#00BFC4", "#F8766D")) + - theme(axis.text.x = element_text(size = 15) + theme(axis.text.x = element_text(size = 10) , axis.text.y = element_text(size = 15 , angle = 0 , hjust = 1 @@ -52,8 +56,12 @@ doMyPlotsStats <- function(df) { , axis.title.x = element_blank() , axis.title.y = element_blank() , legend.position = "none" - , plot.subtitle = element_text(size = 20, hjust = 0.5) - , plot.title = element_text(size = 20, hjust = 0.5)) + + , plot.subtitle = element_text(size = 14, hjust = 0.5) + , plot.title = element_text(size = 14, hjust = 0.5) + #, panel.grid.major = element_blank() + , panel.grid.minor = element_blank() + ) + + labs(title = i) #-------- @@ -66,7 +74,7 @@ doMyPlotsStats <- function(df) { group_by(timepoint, mediator) %>% wilcox_test(value ~ obesity, paired = F) %>% add_significance("p") - stat_df$p_format = round(stat_df$p, digits = 3) + stat_df$p_format = round(stat_df$p, digits = 2) stat_df <- stat_df %>% add_xy_position(x = "timepoint", dodge = 0.8)