今天在ggplot2中使用sample()时遇到了一个有趣的问题。有人能指出我的解决方案吗?
library(ggplot2)
dat <- data.frame("xvar"=runif(500, 1, 10),
"yvar"=runif(500, 1, 10))
#works
ggplot(data=dat, aes(x=sample(xvar, 50), y=sample(yvar, 50)))+
geom_point()
#doesn't work
ggplot(data=dat, aes(x=sample(xvar, 60), y=sample(yvar, 60)))+
geom_point()