我用ggplot2绘制数据帧的子集时遇到问题.我的df是这样的:
df = data.frame(ID = c('P1', 'P1', 'P2', 'P2', 'P3', 'P3'),
Value1 = c(100, 120, 300, 400, 130, 140),
Value2 = c(12, 13, 11, 16, 15, 12))
我现在怎么能只为ID
S'P1'
和'P3'
绘制Value1
对Value2
呢?
ggplot(subset(df,ID=="P1 & P3") +
geom_line(aes(Value1, Value2, group=ID, colour=ID)))
但我总是收到一个错误.