R 如何在一个绘图上显示多个引导置信区间
如何在R中的一个图上绘制多个自举置信区间? 我创建了一个具有置信区间下限和上限的Excel文档。我想要一个图,其中每年有两个置信区间(线或框都可以),用两种颜色表示a组或B组 我尝试使用R 如何在一个绘图上显示多个引导置信区间,r,confidence-interval,R,Confidence Interval,如何在R中的一个图上绘制多个自举置信区间? 我创建了一个具有置信区间下限和上限的Excel文档。我想要一个图,其中每年有两个置信区间(线或框都可以),用两种颜色表示a组或B组 我尝试使用bwclot函数,但我尝试的代码不起作用 bwplot(Lower+Upper~Year, data=yeargroupboot) 数据: 我无法按照您想要的方式使用bwclot:bwclot(下+上~因子(年)| Site,data=dd)是我得到的最接近的 您可以使用plotCI(来自plotrix或gp
bwclot
函数,但我尝试的代码不起作用
bwplot(Lower+Upper~Year, data=yeargroupboot)
数据:
- 我无法按照您想要的方式使用
:bwclot
是我得到的最接近的bwclot(下+上~因子(年)| Site,data=dd)
- 您可以使用
(来自plotCI
或plotrix
软件包)手动执行此操作李>gplots
- 或者使用
,如下所示:ggplot2
dd <- read.table(header=TRUE,text="
Year Upper Lower Site
2001 123 121 A
2001 115 113 B
2002 127 124 A
2002 114 113 B
2003 145 141 A
2003 100 99 B ")
library("ggplot2"); theme_set(theme_bw())
ggplot(dd)+
geom_linerange(aes(Year,ymin=Lower,ymax=Upper,colour=Site),
position=position_dodge(width=0.25))+
scale_x_continuous(breaks=2001:2003)
dd
dd <- read.table(header=TRUE,text="
Year Upper Lower Site
2001 123 121 A
2001 115 113 B
2002 127 124 A
2002 114 113 B
2003 145 141 A
2003 100 99 B ")
library("ggplot2"); theme_set(theme_bw())
ggplot(dd)+
geom_linerange(aes(Year,ymin=Lower,ymax=Upper,colour=Site),
position=position_dodge(width=0.25))+
scale_x_continuous(breaks=2001:2003)