I have a problem to plot a subset of a data frame with ggplot2. My df is like:
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))
How can I now plot Value1
vs Value2
only for ID
s 'P1'
and 'P3'
?
For example I tried:
ggplot(subset(df,ID=="P1 & P3") +
geom_line(aes(Value1, Value2, group=ID, colour=ID)))
but I always receive an error.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…