[R] lapply and dynamically linked functions

Liaw, Andy andy_liaw at merck.com
Wed Feb 11 13:54:50 CET 2004


My guess is that you probably refer to `mylist' instead of `x' inside
`myfun'.  Please show us the entire code, rather than leave us guessing.

Andy

> From: Jason Nielsen
> 
> Hi all,
> 
> I'm trying to use lapply on a list with the following command:
> 
> out<-lapply(mylist,myfun,par1=p,par2=d)               (1)
> 
> where
> 
> myfun<-function(x,par1,par1) {.....}                  (2)
> 
> now this function is in fact a wrapper for some Fortran code I have
> written so I think this might be the problem.  When I call 
> lapply() as in
> (1)  I get the following message:
> 
> Error in get(x, envir, mode, inherits) : variable "mylist" 
> was not found
> 
> but if I say do:
> 
> out<-lapply(mylist,sum)
> 
> it returns a nice list with the sums of the elements in the list.  So
> after all that I guess my question is does this have to do 
> with the fact
> that my function is a wrapper for my Fortran code (which 
> works fine on its
> own.. and if I use a loop as opposed to lapply() )?  I 
> imagine that lapply
> which is a wrapper for the .Internal lapply might have some 
> trouble with
> my Fortran wrapper?  Is this the case or is it something dumb 
> on my end?  
> Any input is appreciated.
> 
> Cheers,
> Jason
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}




More information about the R-help mailing list