I would like to create multiple scatterplots with lines joining all the point in each hospital group.
> 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
My attempt so far is :
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")
But I have been unable to join the dots in each group. geom_line() does not seem to work – it joins all the point, rather than joining the points in each hospital group seperately (and with the same colour as the point for each group)
You should add argument
group=hospitalto functionggplot()to join points.