>>>>> "John" == John Zhong <John_Zhong at
hgsi.com> writes:
> Dear Group:
> I have been trying to write an R function within which the
> function groupedData() would be used. The following is a sample
> program:
>#######################
> sid<-rep(1:6,times=2)
> time<-c(1:12)
> trt<-rep(letters[1:3],times=4)
> tem<-data.frame(sid,time,trt)
> test1.fun<- function(dat=dat)
> {
> groupedData(time ~ trt|sid, data=dat)
> }
> test1.fun(dat=tem)
> ########################
> However, when I ran this kind of program in R, I got the following
> error message:
> Error in as.character(table) : Object "dat" not found.
> Could anyone please help me specify the parameters in the function
> groupedData() so that it would work within my self-created local
> function?
This is a bug in the groupedData function - basically a leftover from
the original S version. We never caught it because we never tried to
use the groupedData function inside another function.
To Doug Bates:
It seems that we will have to upload a fix for this. The problem is in
the following lines -
mCall <- as.list(match.call())[-1]
if (length(grpForm) == 1) {
## single grouping variable
do.call("nfGroupedData", mCall)
} else { # multiple nesting
do.call("nmGroupedData", mCall)
}
These should be changed to
mCall <- match.call()
if (length(grpForm) == 1) {
mCall[[-1]] <- as.name("nfGroupedData")
eval(mCall, envir = parent.frame)
} else {
mCall[[-1]] <- as.name("nmGroupedData")
eval(mCall, envir = parent.frame)
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._