[R] Scatter plot for repeated measures

arun smartpink111 at yahoo.com
Sat Dec 6 09:24:03 CET 2014

Not sure whether it is a scatterplot or just a plot with 3 lines.  If it is the latter,


matplot(acast(my.df, TIME~ID, value.var='X'), type='l', col=1:3, ylab='X', xlab='TIME')
legend('bottomright', inset=.05, legend=LETTERS[1:3], pch=1, col=1:3)

On Friday, December 5, 2014 5:45 PM, farnoosh sheikhi <farnoosh_81 at yahoo.com> wrote:

Hi Arun,

I hope you are doing well.
I have a data set as follow:
my.df <- data.frame(ID=rep(c("A","B","C"), 5), TIME=rep(1:5, each=3), X=1:5)

I would like to get a scatterplot where x axis is Time (1,2,3,4,5) and y axis is X, but I want to have three lines separately for each ID.
 I basically want to tack each ID over time. Is this possible?

Thanks a lot and Happy Holidays to you!

More information about the R-help mailing list