Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用ggplot2(R)绘制单个置信区间?_R_Ggplot2 - Fatal编程技术网

如何使用ggplot2(R)绘制单个置信区间?

如何使用ggplot2(R)绘制单个置信区间?,r,ggplot2,R,Ggplot2,我试图用ggplot在单个图形上显示单个置信区间 当前代码 d1<-rnorm(50,26,6) d2<-rnorm(20,19,4) all_test<-t.test(d1,d2) mean_CI<-(all_test$conf.int[2]+all_test$conf.int[1])/2 ggplot(data.frame(x=c()), aes(x)) + geom_segment(aes(x = 0, y = all_test$conf.int[

我试图用
ggplot
在单个图形上显示单个置信区间

当前代码

d1<-rnorm(50,26,6) 
d2<-rnorm(20,19,4)
all_test<-t.test(d1,d2)
mean_CI<-(all_test$conf.int[2]+all_test$conf.int[1])/2

  ggplot(data.frame(x=c()), aes(x)) +
     geom_segment(aes(x = 0, y = all_test$conf.int[1], xend = 0, yend = all_test$conf.int[2]),  arrow = arrow(length = unit(0.02, "npc"),type = "closed",ends="both")) +   
     annotate("point", x = 0, y = mean_CI,size =4)+
     geom_hline(yintercept = 0, linetype = 3, size =1.5) +
     theme_classic()


d1使用
geom_errorbar
geom_point
可以这样实现:

库(ggplot2)
种子(42)
d1