[R] ?? hmm ??

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Tue Sep 11 15:41:03 CEST 2001


To add to the other answers, 
  1) Normally, the last statement in a function determines its return value.
  2) Normally, when a function returns to the top level (the ">" prompt),
its value is printed by calling print().

Thus your function returns the value of "m", which gets printed when it
returns to the top level.  To see the value of "x", you can either return it
and the value of "m" by changing the last line to "return(x,m)", or you can
call "print(x)" inside the function.

-Greg
 

-----Original Message-----
From: Gerard.Keogh at cso.ie [mailto:Gerard.Keogh at cso.ie]
Sent: Monday, September 10, 2001 11:18 AM
To: r-help at hypatia.math.ethz.ch
Subject: [R] ?? hmm ??


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
}

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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