My data looks like this.
我的数据是这样的。
Serial No. Control Treatment Total Status Type
1 2 4 6 social high
2 3 5 8 social low
3 7 8 15 solitary high
4 8 2 10 solitary low
.
.
.
And several more such rows. I want to produce a final graph where I can place mean control, mean treatment and mean total for each of the Status-Types with confidence intervals.
还有一些这样的行。我想要生成一个最终的图在这里我可以对每个状态类型进行均值控制,均值处理和均值总计具有置信区间。
So in the the end, I will have 4 categories on x-axis solitary high, solitary low, social high, social low : each with its corresponding mean control, treatment, total stacked side-by-side.
所以最后,我将在x轴上有4个类别分别是孤独高,孤独低,社会高,社会低:每一个都有相应的均值控制,处理,全部并排堆放。
Thanks! PS I am newbie to ggplot2
谢谢!我是新手
1 个解决方案
#1
0
First Melt you data:
首先融化你数据:
data <- melt(your_data, c(1, 5,6)
ggplot with facets:
ggplot方面:
ggplot(data , aes(variable, value)) +
stat_summary(fun.data = 'mean_cl_normal', geom = "bar") +
stat_summary(fun.data = 'mean_cl_normal', geom = "errorbar", width = 0.5)
I have used mean_cl_normal
but you can also use mean_sdl
or mean_se
or mean_cl_boot
as your need. See about these function on help.
我已经使用了mean_cl_normal但是您也可以根据需要使用mean_sdl或mean_se或mean_cl_boot。看看这些功能的帮助。
#1
0
First Melt you data:
首先融化你数据:
data <- melt(your_data, c(1, 5,6)
ggplot with facets:
ggplot方面:
ggplot(data , aes(variable, value)) +
stat_summary(fun.data = 'mean_cl_normal', geom = "bar") +
stat_summary(fun.data = 'mean_cl_normal', geom = "errorbar", width = 0.5)
I have used mean_cl_normal
but you can also use mean_sdl
or mean_se
or mean_cl_boot
as your need. See about these function on help.
我已经使用了mean_cl_normal但是您也可以根据需要使用mean_sdl或mean_se或mean_cl_boot。看看这些功能的帮助。