library(openxlsx)
data <- read.xlsx("pone.0226832.s001.xlsx")
# data[,1:3]だけ使います。
# そこの3列を1列に変換します。変換した先の列の名前をvariableとします。
library(reshape2)
ggdata <- reshape2::melt(data[,1:3],
variable.name="variable", value.name="value")
library(ggplot2)
ggplot(ggdata, aes(y = value, x = variable, fill = variable, colour = variable, group = variable)) +
stat_summary(fun.y = "mean", geom = "bar", width = 0.8, position = position_dodge(width = .8), fill="grey") +
stat_summary(fun.y = "mean", fun.ymin = function(x)mean(x)-sd(x), fun.ymax = function(x)mean(x) + sd(x), geom = "pointrange",
position = position_dodge(width = .6) ) +
geom_point(position = position_jitterdodge(dodge.width = .6, jitter.width = 0.6, jitter.height = 0)) +
theme_light() + labs(x = "Exp condition", y = "Task performance") +
theme(axis.title.x = element_text(size=16, family = "Arial"),
axis.title.y = element_text(size=16, family = "Arial"),
axis.text.x = element_text(size=12, colour = 1, family = "Arial"),
axis.text.y = element_text(size = 12, colour = 1, family = "Arial")) +
scale_y_continuous(expand = c(0, 0), limits = c(0,22))
ggplot(ggdata, aes(x = variable, y = value, colour=variable, fill=variable)) +
geom_boxplot(alpha = 0.8) +
labs(x = "Exp condition", y = "Task performance") +
theme_classic() +
theme(axis.title.x = element_text(size=16, family = "Arial"),
axis.title.y = element_text(size=16, family = "Arial"),
axis.text.x = element_text(size=12, colour = 1, family = "Arial"),
axis.text.y = element_text(size = 12, colour = 1, family = "Arial")) +
scale_y_continuous(expand = c(0, 0), limits = c(0,22))
ggplot(ggdata, aes(x = variable, y = value,colour=variable,fill=variable)) +
geom_violin(alpha = 0.4) +
labs(x = "Exp condition", y = "Task performance") +
theme_classic() +
theme(axis.title.x = element_text(size=16, family = "Arial"),
axis.title.y = element_text(size=16, family = "Arial"),
axis.text.x = element_text(size=12, colour = 1, family = "Arial"),
axis.text.y = element_text(size = 12, colour = 1, family = "Arial")) +
scale_y_continuous(expand = c(0, 0), limits = c(0,22))