[R] Return od functions

wangchi3 wangchi3 at netscape.net
Sun Jul 29 09:24:18 CEST 2012


Hi!
I have some questions about R function. I try to write a function for
multi-returns. The function code is as attachment. 

dgp.par<-function(ai, bi, t, n)
{ 
t0<-t+20
y0<-matrix(0, nr=t0, nc=n)
y0[1,]<-ai/(1-bi)
 
for(tt in 2:t0)
{ y0[tt,]<-ai+bi*y0[tt-1,]+rnorm(n, 0, 1) }
y<-y0[21:t0,]
x<-y0[20:t0-1,]
z<-y0[19:t0-2,]
z<-z[2:t,]
dy<-y[2:t,]-y[1:t-1,]
dx<-x[2:t,]-x[1:t-1,]
return(y, x, z, dy, dx)
}

When I execute the function I wrote, it always appears an error message that
function cannot have multi-returns. Whether the R functions only allow
single return? If the R function can allow multi-returns, how do I rewrite
my R function to allow multi-returns?

Thanks a lot.

Eric Wang






--
View this message in context: http://r.789695.n4.nabble.com/Return-od-functions-tp4638247.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list