本文介绍了具有计算的置信区间和计算的均值的r中的横线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的桌子看起来像这样:

my table looks like this:

    name                 mean        confi_low      confi_high
    factor 1            0.107929704  -0.005593772   0.221453181
    factor 2            0.166226365   0.069457719   0.262995011
    factor 3            -0.080056702 -0.200222151   0.040108748
    factor 4            0.158344295   0.025713561   0.290975028
    factor 5            0.188088223  0.097130584    0.279045862
    factor 6            0.097839971 -0.008014220    0.203694161

我想创建一个以confi_low为下边界,confi_high为上边界并标记均值的交叉图.谁能帮我?我非常感谢每一个提示

I would like to create a crossbar graph that has confi_low as lower border, confi_high as upper border and mean marked. Can anyone help me?I am very thankful for every hint

推荐答案

我也不会为此使用Boxplots.您可以制作带有错误栏的条形图:

I also wouldn't use Boxplots for that. You could make a barplot with errorbars:

library(ggplot2)
ggplot(df, aes(x = name, y = mean)) +
  geom_col() +
  geom_errorbar(aes(ymin = confi_low, ymax = confi_high)) +
  theme_bw() +
  labs(title = c("mean and 95% CI"))

或使用 geom_point :

ggplot(df, aes(x = name, y = mean)) +
  geom_point(size = 2) +
  geom_errorbar(aes(ymin = confi_low, ymax = confi_high), width = 0.3) +
  theme_bw() +
  labs(title = c("mean and 95% CI"))

编辑绘制意味着按升序排列:

EditPlot means in ascending order:

ggplot(df, aes(x = fct_reorder(name, mean), y = mean)) +
  geom_point(size = 2) +
  geom_errorbar(aes(ymin = confi_low, ymax = confi_high), width = 0.3) +
  theme_bw() +
  labs(title = c("mean and 95% CI"))

这篇关于具有计算的置信区间和计算的均值的r中的横线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 16:05