I'm puzzled by the following problem, which appears when attempting to run an analysis on part of a dataset: If I try: csubset <- dat$Diagnosis==0 cont <- lme(fixed=cform, random = ~1|StudyName, data=dat,subset=csubset,na.action=na.omit) Then I get: Error in eval(expr, envir, enclos) : Object "csubset" not found But if I do instead: cdat <- dat[dat$Diagnosis==0,] cont <- lme(fixed=cform, random = ~1|StudyName, data=cdat,na.action=na.omit) Then everything is fine. I'm puzzled that the object can't be found. Maybe I'm overlooking something obvious? Best, Todd Ogden
Hoi Todd, --On woensdag 16 juni 2004 10:18 -0400 Todd Ogden <to166 at columbia.edu> wrote:> I'm puzzled by the following problem, which appears when > attempting to run an analysis on part of a dataset: > > If I try: > > csubset <- dat$Diagnosis==0 >This just creates a vector of booleans that indicate (the row numbers) for which positions in dat Diagnosis==0.> > cdat <- dat[dat$Diagnosis==0,] >This OTOH, uses the above vector to index the rows of dat, indeed selecting those rows from dat that have Diagnosis==0. This is assigned to cdat. You could have done cdat <- dat[csubset,] as well HTH -- Paul Lemmens NICI, University of Nijmegen ASCII Ribbon Campaign /"\ Montessorilaan 3 (B.01.05) Against HTML Mail \ / NL-6525 HR Nijmegen X The Netherlands / \ Phonenumber +31-24-3612648 Fax +31-24-3616066
Todd Ogden wrote:> I'm puzzled by the following problem, which appears when > attempting to run an analysis on part of a dataset: > > If I try: > > csubset <- dat$Diagnosis==0 > cont <- lme(fixed=cform, > random = ~1|StudyName, > data=dat,subset=csubset,na.action=na.omit) > > Then I get: > > Error in eval(expr, envir, enclos) : Object "csubset" not found > > But if I do instead: > > cdat <- dat[dat$Diagnosis==0,] > cont <- lme(fixed=cform, > random = ~1|StudyName, > data=cdat,na.action=na.omit) > > Then everything is fine. > > I'm puzzled that the object can't be found. Maybe I'm > overlooking something obvious? >Todd, What version of R/nlme? I just tried the following: library(nlme) data(Orthodont) csubset <- Orthodont$Sex == "Male" fm1 <- lme(distance ~ age, data = Orthodont, random = ~ 1, subset = csubset) fm2 <- lme(distance ~ age, data = Orthodont, random = ~ 1, subset = Sex == "Male") fm3 <- lme(distance ~ age, data = Orthodont[csubset, ], random = ~ 1) > R.version.string [1] "R version 1.9.0, 2004-05-06" R> library(help = "nlme") Information on Package 'nlme' Description: Package: nlme Version: 3.1-48 Date: 2004/01/14 <snip> --sundar