Re: [R] function with Multiple Output

2007-03-05 Thread Levent TERLEMEZ
With help of list(), function can return ala of the results.
 
my.fun=function(vector, index){
a=fun.a(vector, index)
b=fun.b(vector, index)
return(list(a,b))
}

Example:
R : Copyright 2005, The R Foundation for Statistical Computing
Version 2.2.1  (2005-12-20 r36812)
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 fix(multiresult)
 multiresult(rnorm(10,0,1))
[[1]]
[1] -0.1240271

[[2]]
[1] 1.037070

__
R-help@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.


Re: [R] function with Multiple Output

2007-03-02 Thread jim holtman
my.fun=function(vector, index){
   a=fun.a(vector, index)
   b=fun.b(vector, index)
   return(list(a=a, b=b))
   }



On 3/1/07, Claudio Isella [EMAIL PROTECTED] wrote:

 Dear R user,


 I have a simple question for you: I have created a global function that
 evoke other subsidiary functions. when I run the global function I want
 to store the outcomes of the of each subsidiary function into a
 variables. an examples

 my.fun=function(vector, index){
a=fun.a(vector, index)
b=fun.b(vector, index)
}


 if i use return() I can only retrive one single results. what can I do
 to store the outcome of the two function in differnt enviroment
 variables?


 --
 Claudio

 __
 R-help@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?

[[alternative HTML version deleted]]

__
R-help@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.


[R] function with Multiple Output

2007-03-01 Thread Claudio Isella
Dear R user,


I have a simple question for you: I have created a global function that
evoke other subsidiary functions. when I run the global function I want
to store the outcomes of the of each subsidiary function into a
variables. an examples

my.fun=function(vector, index){
a=fun.a(vector, index)
b=fun.b(vector, index)
}


if i use return() I can only retrive one single results. what can I do
to store the outcome of the two function in differnt enviroment
variables?


--
Claudio

__
R-help@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.