Full_Name: James Signorovitch Version: 2.2.1 OS: WinXP Submission from: (NULL) (134.174.182.203)
In the code below, fn1() and fn2() fail with the messages given in the comments. Strangely, fn2() fails for all data sets I've tried except for those with 100 rows. The same errors occur if glm() is used in place of lm(), or if R 2.1.1 is used on a unix system. Thanks for looking into this. JS fn1 <- function(model, data) { w <- runif(nrow(data)); print(lm(model, data=data, weights=w)); } fn2 <- function(model, data) { print(lm(model, data=data, weights=runif(nrow(data)))); } n = 101; A <- data.frame(matrix(rnorm(2*n), n, 2)); names(A) <- c("x", "y"); # we can run the command print(lm(y ~ x, data=A, weights=runif(nrow(A)))); # But fn1() generates the error message # # Error in eval(expr, envir, enclos) : object "w" not found # fn1(y ~ x, data=A); # fn2() generates the error message: # Error in model.frame(formula, rownames, variables, varnames, extras, extranames, : # variable lengths differ # # # But fn2() works if n=100 fn2(y ~ x, data=A); # note: the error in fn1() still occurs if w <- 1:nrow(data); ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel