[Rd] data.frame within a function (PR#9294)
Duncan Murdoch
murdoch at stats.uwo.ca
Thu Oct 12 19:54:09 CEST 2006
On 10/12/2006 1:45 PM, rcheng at purdue.edu wrote:
> Full_Name: Riyan Cheng
> Version: windows 2.0.1
This version is really quite ancient. The current release is 2.4.0.
> 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.
If the problem still exists, then please say what the results are that
you get, and why you think they are not correct.
Duncan Murdoch
> 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.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list