[Rd] default data= arg to glm() (PR#844)
pperkins@ucsd.edu
pperkins@ucsd.edu
Fri, 9 Feb 2001 23:04:43 +0100 (MET)
Full_Name: Peter Perkins
Version: 1.2.1
OS: LinuxPPC
Submission from: (NULL) (24.4.89.36)
the lines
if (missing(data))
data <- environment(formula)
in glm() seem to contradict the documentaton:
data: an optional data frame containing the variables in the model.
By default the variables are taken from the environment from
which `glm' is called.
actually, the near lack of other references to "data" is glm() is not
clear to me, so i may have this wrong. but a small test seems to bear
out the problem:
function ()
{
form <- y ~ x
fun1 <- function(f)
{
n <- 10
x <- runif(n, 1, 10)
y <- rpois(n, x)
glm(f, family=poisson(link="log"), data=environment())
}
fun2 <- function(f)
{
n <- 10
x <- runif(n, 1, 10)
y <- rpois(n, x)
glm(f, family=poisson(link="log"))
}
print("fit1")
print(fun1(form)$call)
print("fit2")
print(fun2(form)$call)
}
> test()
[1] "fit1"
glm(formula = f, family = poisson(link = "log"), data = environment())
[1] "fit2"
Error in eval(expr, envir, enclos) : Object "y" not found
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._