segun ogundimu wrote:
Hello R-users
Kindly assist me with the following plot problem in R-
My data looks like this (shortened because I have about 5000 observations).
dat <- read.table(textConnection("Id Time Y 1 0 194
1 5.22 179
1 5.97 190 2 1.61 265 2 2.1 234 2 16.4 300 2 29.5 345 3 0 212 3 0.36 213 4 0 199
4 1.23  203
5  0   212
5  13.5 216
6  0    222
6  1.6 234" ), header = TRUE)
closeAllConnections()
The measurements are not taken at equal time points. I want to avoid overly cluttered plots in making individual profile. So, I will like the profile plot to appear grey (not completely visible) and about 30 randomly selected 'lucky subjects' to appear dark(very visible).
Hi segun,
Will this do the job?

luckyones<-sample(unique(dat$Id),3)
plot(dat$Time,dat$Y,type="n",main="The luck of the drawing",)
for(subid in unique(dat$Id))
lines(dat$Time[dat$Id == subid],dat$Y[dat$Id == subid],
col=ifelse(subid %in% luckyones,"black","lightgray"))

Jim

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to