View source: R/dotplot_bin_sig.R
1 | dotplot_bin_sig(select, variable, testdata, folder, method = "kruskal.test", s = 15)
|
select |
|
variable |
|
testdata |
|
folder |
|
method |
|
s |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (select, variable, testdata, folder, method = "kruskal.test",
s = 15)
{
library(ggplot2)
library(see)
dir.create(path = folder, showWarnings = FALSE)
binwidth = (max(testdata[[select]], na.rm = T)/2 - mean(testdata[[select]],
na.rm = T))/s
stackratio = 1
dotsize = 1.2
p <- ggplot(testdata, aes_string(x = variable, y = select,
fill = variable, group = variable)) + geom_dotplot(binaxis = "y",
stackdir = "center", position = "identity", method = "dotdensity",
binwidth = binwidth, stackratio = stackratio, dotsize = dotsize) +
scale_y_continuous(labels = function(x) format(x, scientific = TRUE)) +
scale_fill_manual(values = c("#00b0f6", "#f8766d")) +
stat_summary(fun.ymin = function(z) {
quantile(z, 0.025)
}, fun.ymax = function(z) {
quantile(z, 0.975)
}, fun.y = median, shape = 18, size = 2, geom = "pointrange",
color = "black", show.legend = FALSE) + ggpubr::stat_compare_means(method = method,
size = 10) + ylim(-0.1 * max(testdata[[select]]), 1.1 *
max(testdata[[select]])) + theme_bw() + theme(plot.title = element_text(size = 24,
face = "bold"), legend.title = element_text(size = 20),
legend.text = element_text(size = 16)) + theme(axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(), panel.border = element_blank(),
panel.background = element_blank(), axis.line.x = element_line(color = "black",
size = 1), axis.line.y = element_line(color = "black",
size = 1), axis.text = element_text(size = 16, face = "bold"),
axis.title = element_text(size = 20, face = "bold"))
p
ggsave(filename = paste(folder, "/", select, ".pdf", sep = ""),
width = 10, height = 7)
return(select)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.