[R] How to return multiple values in a function

Gundala Viswanath gundalav at gmail.com
Mon Jun 23 10:23:19 CEST 2008


Hi,

I apologize for this newbie question. But I can't seem
to find in R online manual.

1. How can I return two values in a function?
2. How can I capture the values again of this function?

myfunc <- function (array) {

    # do something with array
    # get something assign to "foo" and "bar"
    print(foo)
    print(bar)

   # how can I return "foo" and "bar" ?
}

# Is this the way to capture it?

(nfoo,nbar) <- myfunc(some_array)

- Gundala Viswanath
Jakarta - Indonesia



More information about the R-help mailing list