Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 具有连接线的多个散点图_R_Ggplot2 - Fatal编程技术网

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
似乎可以使用一个比最后一个更明显的例子来说明
组的使用。(我猜一开始也有一个…)