On Wed, Jul 8, 2009 at 5:34 PM, Jason Rupert<jasonkrup...@yahoo.com> wrote:
>
> Maybe there is a great website out there or white paper that discusses this 
> but again my Google skills (or lack there of) let me down.
>
> I would like to know the best way to export several doubles from a function, 
> where the doubles are not an array.
>
> Here is a contrived function similar to my needs:
>
> multipleoutput<-function(x)
> {
>        squared<-x^2
>        cubed<-x^3
>        exponentioal<-exp(x)
>        factorialVal<-factorial(x)
>
> }
>
> Thanks again for all your help.
>
> ______________________________________________
> R-help@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.
>

I'm a newbie so mine;s probably not the best but it seems to work:

multipleoutput<-function(x)
{
        answer<- c(0,0,0,0)
        MyFuncNames <- c("Squared","Cubed","Exp","Fac")
        answer$squared<-x^2
        answer$cubed<-x^3
        answer$exponential<-exp(x)
        answer$factorial<-factorial(x)
        return(answer)
}

X = c(0,0,0,0)
X
mode(X)
names(X)

MyNames = c("Squared","Cubed","Exp","Fac")
MyNames

names(X) = MyNames
X <- multipleoutput(2)

X
class(X)

dim(X)

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

Reply via email to