Re: [R] multiple return

From: Mahbub Latif <mlatif_at_isrt.ac.bd>
Date: Fri, 22 Jun 2007 17:20:01 +0600

one way --

somma <- function (a, b) {
  c <- a+b
  return (list(a=a, b=a, c=c))
}

Mahbub.

On 6/22/07, Manuele Pesenti <amicogodzilla_at_bruttocarattere.org> wrote:
>
> Dear User,
> what's the correct way to obtain a multiple return from a function?
>
> for example creating the simple function:
>
> somma <- function (a, b) {
> c <- a+b
> return (a, b, c)
> }
>
> when I call it, it runs but returns the following output:
>
> > somma(5, 7)
> $a
> [1] 5
>
> $b
> [1] 7
>
> $c
> [1] 12
>
> Warning message:
> return multi-argomento sono deprecati in: return(a, b, c)
>
> i.e. multi-return is deprecated...
>
> thanks a lot
> best regards
> Manuele
>
> --
> Manuele Pesenti
> manuele_at_inventati.org
> amicogodzilla_at_jabber.linux.it
> http://mpesenti.polito.it
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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.
>

-- 
A H M Mahbub Latif, PhD
Assistant Professor
Applied Statistics
Institute of Statistical Research and Training
University of Dhaka, Dhaka 1000, Bangladesh
web : http://www.isrt.ac.bd/mlatif
----
Computers are like airconditioners: They stop working properly if you open
windows.

	[[alternative HTML version deleted]]

______________________________________________
R-help_at_stat.math.ethz.ch 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 Fri 22 Jun 2007 - 11:31:00 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 Fri 22 Jun 2007 - 12:32:13 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.