[R] assigning multiple outputs
Petr PIKAL
petr.pikal at precheza.cz
Fri Nov 18 09:11:36 CET 2011
Hi
>
> Hi All,
>
> So I figured out how to do multiple outputs, but whats the best/
> recommended way of assigning them.
>
> f<-function{a=1; b=1; list(a,b)}
I get an error
> f<-function{a=1; b=1; list(a,b)}
Error: unexpected '{' in "f<-function{"
and I wonder what do you want.
f<- function(a=1, b=1) { list(a,b)}
f()
[[1]]
[1] 1
[[2]]
[1] 1
f(2,2)
[[1]]
[1] 2
[[2]]
[1] 2
If you do not want this so please send code example with desired output
resul.
Regards
Petr
>
> I want to be able to say assign into a and b straight away rather that
> doing a=f()[[1]] and b=f()[[2]]. It would be best if I can get around
this
> without having to assigning this to a third dummy variable.
>
> Thanks,
> Sachin
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list