[Rd] cannot wrap lmekin function

From: Qiong Yang <qyang_at_bu.edu>
Date: Mon, 11 Jun 2007 14:59:03 -0400


Hi,

I had a problem with the lmekin() in Kinship package: lmekin() can not be wrapped into another function

For example:

library(kinship)
#creat an example dataset

xx<-rnorm(100);yy<-rnorm(100) ;id<-1:100; test.dat<-as.data.frame(cbind(xx,yy,id)) ; rm(xx,yy,id) a<-bdsmatrix(rep(10,10),rep(block,10),dimnames=list(c(1:100),c(1:100)))

#this works: call lmekin directly

lmekin(yy~xx,random=~1|id,data=test.dat,varlist=a,na.action=na.omit)

#this doesn't work: wrap lmekin into another function

fo<-function(x,y,z,data)lmekin(y~x,random=~1|z,data=test.dat,varlist=a,na.action=na.omit)

fo(xx,yy,id,data=test.dat)

Error in eval(expr, envir, enclos) : Object "y" not found

I did line by line debug within lmekin(). I found the problem was from line #25
m <- eval(m, sys.parent())

Here is the print(m) result before this line [1] model.frame(data = data, na.action = na.omit, formula = y ~ x +z)

It seems data cannot be passed to the arguments when lmekin() is wrapped into another function.
Can anyone help me to figure a fix?

Thanks a lot!

Qiong



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 11 Jun 2007 - 19:03:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 11 Jun 2007 - 23:34:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.