[R] How to return multiple values in a function

From: Gundala Viswanath <gundalav_at_gmail.com>
Date: Mon, 23 Jun 2008 17:23:19 +0900


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)


R-help_at_r-project.org mailing list
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. Received on Mon 23 Jun 2008 - 08:28:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 23 Jun 2008 - 09:31:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive