> On Sep 25, 2016, at 6:43 PM, John Sorkin <jsor...@grecc.umaryland.edu> wrote: > > I have a data frame that contains data for multiple (seven) subjects. Each > subject is represented by a new value of PID. > I would like to plot the data for all seven subjects. For each subject I want > to plot a line showing CT as a function of Nit, with the dots for each > subject joined. I have tried to accomplish this using the by function. I get > an error message, > Error in match.fun(panel) : > 'xx[, "CT"]' is not a function, character or symbol > I have no idea what is causing the error, nor how to correct the error, nor > how to get the dots for each point be connected by a line. > > > Any help would be appreciated! > > > PID <- c( 1 , 1 , 1 , 1 , 2, 2, 2, 2, 3 , 3 , 3 , 3 , 4 > , 4, 4, 4 , 5, 5, 5, 5, 6, 6, 6, 6, 7 , 7 , 7 , 7) > Nit <- c(NA , -9.23,-11.61,-7.88,NA,NA,NA,NA,-5.59, 0.73,-10.55, -9.13, > 3.67, NA, NA,-13.26,NA,NA,NA,NA,NA,NA,NA,NA,-9.36, 5.08, -5.73, 2.02) > CT <- c(544,459 ,432 ,NA ,NA,NA,NA,NA,1398 ,1287 ,1049 , NA ,543 > ,474,507,NA ,NA,NA,NA,NA,NA,NA,NA,NA,992 ,992 ,1078 ,NA) > xx <- data.frame(PID=PID,Nit=Nit,CT=CT) > xx > by(xx,as.factor(xx[,"PID"]),plot,xx[,"Nit"],xx[,"CT"])
Wouldn't this just be: library(lattice) xyplot( CT ~ Nit, group= PID, data=xx, type="b") -- David (MD, MPH) > John David Sorkin M.D., Ph.D. David Winsemius Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.