[R] subset arg lmList
Sebastian Luque
sluque at mun.ca
Fri Apr 8 23:57:49 CEST 2005
I'm having trouble understanding how functions in the subset argument for
lmList search for the objects they need. This trivial example produces
"Error in rownames(fakedf) : Object "fakedf" not found":
library(nlme)
fitbyID <- function() {
fakedf <- data.frame(ID = gl(5, 10, 50),
A = sample(1:100, 50),
B = rnorm(50))
mycoefs <- lmList(B ~ A | ID,
data = fakedf,
subset = !is.element(rownames(fakedf),
c("3", "10")))
coef(mycoefs)
}
fitbyID()
If fakedf is already in the workspace, then the function runs fine, so
rownames seems to be looking for it in the global environment, although
I'd expect it to search locally first. I suspect this shows some gaps in
my understanding of environments and related concepts. I'd be grateful for
some advice on this.
Best wishes,
--
Sebastian P. Luque
More information about the R-help
mailing list