From rcheng at purdue.edu  Thu Oct 12 19:45:24 2006
From: rcheng at purdue.edu (rcheng at purdue.edu)
Date: Thu, 12 Oct 2006 19:45:24 +0200 (CEST)
Subject: [Rd] data.frame within a function (PR#9294)
Message-ID: <20061012174524.9270B4C916@slim.kubism.ku.dk>

Full_Name: Riyan Cheng
Version: windows 2.0.1
OS: windows xp
Submission from: (NULL) (74.140.105.186)



If one runs the following function ff(), an error would occur regarding
data.frame():
  ff<- function(){
     x<- rnorm(10)
     y<- rnorm(10)
     lm1<- lm(y~1,data=data.frame(y=y,x=x)); cat("ok\n")
     update(lm1,~ .+x,evaluate=T); cat("also ok\n")
     add1(lm1, ~ .+x);  cat("again ok\n")
  }
  ff()
But if there are external variables y and x, one would not get correct results.
This problem does not exist if one directly runs the body of the function:
  x<- rnorm(10)
  y<- rnorm(10)
  lm1<- lm(y~1,data=data.frame(y=y,x=x)); cat("ok\n")
  update(lm1,~ .+x,evaluate=T); cat("also ok\n")
  add1(lm1, ~ .+x);  cat("again ok\n")

There is exactly the same problem in Unix version.




[Rd] data.frame within a function (PR#9294)
rcheng at purdue.edu