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.
Let’s create some data:
Then to create a plot in base graphics, we create an initial plot of one group:
then iteratively add on the lines:
I’ve used
type="b"to show the points and the lines.Alternatively, using ggplot2: