@agstudy's answer didn't work for me with the latest version of ggplot2
, but this did, using maggritr
pipes:
ggplot(data=dat)+
geom_line(aes(Value1, Value2, group=ID, colour=ID),
data = . %>% filter(ID %in% c("P1" , "P3")))
It works because if geom_line
sees that data
is a function, it will call that function with the inherited version of data
and use the output of that function as data
.