Group data and plot multiple lines
问题 I'd like to plot multiple lines in R for this dataset: (x = Year, y = Value) School_ID Year Value A 1998 5 B 1998 10 C 1999 15 A 2000 7 B 2005 15 Each school has data for different years. I'd like to have one line for each school. 回答1: Let's create some data: dd = data.frame(School_ID = c("A", "B", "C", "A", "B"), Year = c(1998, 1998, 1999, 2000, 2005), Value = c(5, 10, 15, 7, 15)) Then to create a plot in base graphics, we create an initial plot of one group: plot(dd$Year[dd$School_ID=="A"],