我想使用 ggplot 进行以下绘图:
这是我的 df 结构的示例(有点,绘制不与数据按比例绘制):
example.df = data.frame(mean = c(0.3,0.8,0.4,0.65,0.28,0.91,0.35,0.61,0.32,0.94,0.1,0.9,0.13,0.85,0.7,1.3),
std.dev = c(0.01,0.03,0.023,0.031,0.01,0.012,0.015,0.021,0.21,0.13,0.023,0.051,0.07,0.012,0.025,0.058),
class = c("1","2","1","2","1","2","1","2","1","2","1","2","1","2","1","2"),
group = c("group1","group2","group1","group2","group1","group2","group1","group2","group1","group2","group1","group2","group1","group2","group1","group2"))
该数据框由 16 个重复项组成,每个重复项具有给定的平均值和给定的标准偏差。
对于每个重复,我想绘制置信区间,其中我的图形示例中的大点是平均估计值,条形的长度是标准偏差的两倍。
另外我想在同一行绘制两个不同的复制品,但颜色不同,按类别着色,红色是 1 类,蓝色是 2 类。
最后,我想将整个情节分成两个面板(在同一行),对应于两个不同的组。
我试着查看这个网站,http://www.cookbook-r.com/Graphs/Plotting_means_and_error_bars_ (ggplot2)/但无法弄清楚如何为这个结构的任何数据框自动化这个,有X个组(在这种情况下为 2),并且每组重复 K 次(在这种情况下为 8、4 类 1 和 4 类 2)。
有没有使用 ggplot 或标准 r pkg 库的好方法?