[R] ?? hmm ??

Torsten Hothorn Torsten.Hothorn at rzmail.uni-erlangen.de
Tue Sep 11 09:08:08 CEST 2001


> Hello again!
> thanks to all who helped with overlay plots - v.  easy in the end.
> 
> Anyway, another new(ba)bee type question - the gurus will cringe I'm sure!
> 
> Q. simple R function
> mm <- function (u) {
>   x <- u$GDP
>   x
>   m <- mean(x)
>   m
> }

m is returned by the function mm while x is not. If you would like to
return both x and m use

mm <- function (u) {
  x <- u$GDP
  x
  m <- mean(x)
  list(m = m, x = x)
}

which returns a names list with elements m and x

Torsten


> 
> When the function is called the vector "x" does not get printed from within
> the function, but the mean value "m" does, why?
> I think it's probably to do with scoping but don't really know.
> The vector "x" can of course be printed with the print function so there no
> problem seeing it for program debugging etc.
> 
> Thanks in advance.
> 
> Gerard Keogh
> 
> The information in this email, and any attachments transmitted with it, are confidential 
> and are for the intended recipient only. If you receive this message in error, please 
> notify us via postmaster at cso.ie.
> 
> To see the latest figures from the CSO go to http://www.cso.ie
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list