[R] function with Multiple Output
Levent TERLEMEZ
lterlemez at anadolu.edu.tr
Mon Mar 5 12:44:13 CET 2007
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
More information about the R-help
mailing list