我有类似的数据
Value Number
3 1.5
6 1.67
9 1.7
12 1.6
15 1.7
18 1.8
21 1.9
24 1.98
27 1.98
30 1.8
33 1.84
36 1.5
39 1.7
42 1.9
45 1.9
48 2.0
51 1.21
54 1.4
57 2.34
60 2.5
63 2.1
66 1.77
我如何使用标准误差条制作散点图....我查了一下它似乎是这样的
errbar(df$Value, df$Number, yplus, yminus, cap = 0.015,
xlab= deparse(substitute(x)),
ylab= deparse(substitute(y)))
但是我对yplus,yminus不熟悉?和deparse? 还有其他方法吗?我尝试使用ggplot并使用install.packages(ggplot2)下载它,但R一直说它无法找到它并尝试使用此代码
> ggplot(data=dataset,aes(x=df$Value,y=df$Number,colour=Code,linetype=Group,ymin=Mean-SE,ymax=Mean+SE))
Error: could not find function "ggplot"
> + geom_line()
Error: could not find function "geom_line"
> + scale_x_continuous(breaks=c(1,2))
Error: could not find function "scale_x_continuous"
> + scale_linetype_manual(values=c(2,1))
Error: could not find function "scale_linetype_manual"
> + geom_point()
Error: could not find function "geom_point"
> + geom_errorbar(width=.1,position='dodge')
Error: could not find function "geom_errorbar"
另外,我应该如何绘制一个图形中的2个散点图,其中x轴的值相同,并且还显示误差条? 谢谢你们......任何建议都会得到应用
答案 0 :(得分:4)
您看到的错误是因为尚未加载ggplot2
包。将library(ggplot2)
添加到脚本将解决此问题。这当然是假设安装了ggplot2
包。如果没有,请使用install.packages("ggplot2")
来解决此问题。
答案 1 :(得分:0)
或者,您可以使用R的gplots
包非常好且易于处理(至少在我看来)。
# Required package
library(gplots)
# Sample data
x <- seq(3, 66, 3)
y <- c(1.5, 1.67, 1.7, 1.6, 1.7, 1.8, 1.9, 1.98, 1.98, 1.8, 1.84,
1.5, 1.7, 1.9, 1.9, 2.0, 1.21, 1.4, 2.34, 2.5, 2.1, 1.77)
xy <- data.frame(x, y)
# Plotting
plotCI(x, y,
uiw = .5, gap = 0, pch = 22, pt.bg = "green")
当然,您必须使用错误向量替换参数uiw
和liw
。
干杯,弗洛里安