[Rd] cannot wrap lmekin function

Qiong Yang qyang at bu.edu
Mon Jun 11 20:59:03 CEST 2007


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



More information about the R-devel mailing list