R 具有连接线的多个散点图
我想创建多个散点图,用线连接每个R 具有连接线的多个散点图,r,ggplot2,R,Ggplot2,我想创建多个散点图,用线连接每个医院组中的所有点 > head(dt.gg) pred base hospital 1 -1.4273910 -2.596 1 2 -0.7296839 -1.595 1 3 -0.6606799 -1.496 1 4 -0.5993430 -1.408 1 5 -0.5380061 -1.320 1 6 -0.4766692 -1.232 1 到目前
医院
组中的所有点
> head(dt.gg)
pred base hospital
1 -1.4273910 -2.596 1
2 -0.7296839 -1.595 1
3 -0.6606799 -1.496 1
4 -0.5993430 -1.408 1
5 -0.5380061 -1.320 1
6 -0.4766692 -1.232 1
到目前为止,我的努力是:
require(ggplot2)
dt.gg <- read.csv("http://goo.gl/5yjEZ")
ggplot(dt.gg, aes(x=base, y=pred, color=hospital)) + geom_point(shape=1) +
theme(legend.position="none")
require(ggplot2)
dt.gg您应该将参数group=hospital
添加到函数ggplot()
到连接点
ggplot(dt.gg, aes(x=base, y=pred, color=hospital,group=hospital)) + geom_point(shape=1) +
geom_line()+ theme(legend.position="none")
有趣的是,查看?geom_line
似乎可以使用一个比最后一个更明显的例子来说明组的使用。(我猜一开始也有一个…)