Java Mailing List Archive

http://www.r-help.com/

Home » R Help for Statistical Computing »

Re: [R] return from .Call()

Barry Rowlingson

2010-09-04

Replies: Find Java Web Hosting

Author LoginPost Reply
On Sat, Sep 4, 2010 at 10:17 AM, rajeshj@(protected)
<rajeshj@(protected):
>
> Hi,
>
> I have a .Call in my R function in a loop that repeats a certain number of times. Each time, the .Call returns a list. So, when I say something like,
>
> y<-func()
>
> would y be a list of lists?(as many as the number of loops?)

No, it'll be the last thing evaluated or the result of a return()
call. Why haven't you tried this?

Try a simple example:

func = function(){
for(i in 1:10){
  z=list(a=1,b=2)
 }
}

and see what comes back. My suspicion is its not going to be a list of lists.

If you want a list of lists then you'll have to put the list together
yourself from the returns of the .Call, something like (not tested,
but looks okay):

func = function(){
 ret=list()
 for(i in 1:10){
  ret[[i]]=list(i,i*2,i*3)
  }
  return(ret)
}

Barry

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
©2008 r-help.com - Jax Systems, LLC, U.S.A.