[R] How to return more than one variable from function

jim holtman jholtman at gmail.com
Fri Apr 20 13:38:51 CEST 2007

use a 'list' as the return value containing the values you want returned.

x<- function(){
list(val1=a, val2=b, val3=c)

On 4/20/07, vinod gullu <vinodkgul at yahoo.com> wrote:
> Dera R users,
> I have written a function which computes variance, sd,
> r^2, R^2adj etc. But i am not able to return all of
> them in return statement.
>  So how to return more than one variable from
> function.  In C i used to return by pointers etc. is
> there any way like that.
> Thanks in advance.
> ______________________________________________
> 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.

Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

More information about the R-help mailing list