[R] Add ID numbers on a plot

Steve Hong seunghong at wisc.edu
Mon Jun 29 20:16:40 CEST 2009


Dear List,

I have (for example) 50 observations collected from 50 experimental sites and want to look at changes of 50 observations as function of time in a graph. I found that I could do that using R-code below: 

time2 <- 1:25
y1=rnorm(25, mean=0, sd=1)
y2=rnorm(25, mean=0, sd=1)
...
y50=rnorm(25, mean=2, sd=1)
plot(time2, y1, type='b', xlim=range(0,30), ylim=range(y1, y2), xlab='x', ylab='y', pch="1",col=3)
points(time2, y2, type='b', col="red", xlab='x', ylab='y', pch="2")
...
points(time2, y50, type='b', col="red", xlab='x', ylab='y', pch="50")

Also, I wanted to add IDs of 50 individual sites within each lines but found it does not work using 'pch' within 'points' function. Do you have any suggestion? 

Thank you in advance,

Steve




More information about the R-help mailing list