Skip to content
Prev 326126 / 398503 Next

How to create a function returning an array ?

On 28/06/2013 10:18 AM, Kaptue Tchuente, Armel wrote:
There are several typos in your code above, but I think your intention 
is clear.

You can do what you are asking for, but not with .Fortran.  It only 
handles vectors for input and output.  You'll need to use .Call (which 
means writing in C or C++).  If you're familiar with C++, using Rcpp is 
probably the easiest way to do this.  If not, I'd rewrite the Fortran 
code to avoid the need for the transpose at the end, and do

dim(out$img) <- c(n,m)
return(out$img)

within your read_ts function.  I think this is reasonably efficient.

Duncan Murdoch