我想突出显示选定的点并遇到一些奇怪的行为。首先一些虚拟数据:r - ggplot2 - 突出显示选定的点和奇怪的行为
a <- 1:50
b <- rnorm(50)
mydata <- data.frame(a=a,b=b)
ggplot(mydata,aes(x=a,y=b)) + geom_point()
这个工作正常。现在,要强调几点,我再添geom_point
层:
ggplot(mydata[20:40,],aes(x=a,y=b)) +
geom_point() +
geom_point(aes(x=a[c(10,12,13)],y=b[c(10,12,13)]),colour="red")
注意,我只显示数据([20:40]
)的范围有限。现在到了奇怪的现象:
ggplot(mydata[10:40,],aes(x=a,y=b)) +
geom_point() +
geom_point(aes(x=a[c(10,12,13)],y=b[c(10,12,13)]),colour="red")
更改选定范围的大小,我得到一个错误,从德国大致翻译:Error...: Arguments implying different number of rows
。奇怪的是,这与选定的范围有所不同。 [23:40]
将工作,[22:40]
不会。
英语中的错误是:
Error in data.frame(x = c(19L, 21L, 22L), y = c(0.28198, -0.6215, :
arguments imply differing number of rows: 3, 31
我希望你不介意,但我已在英国 – csgillespie 2012-07-13 09:54:03