Re: [R] ?? hmm ??

About this list Date view Thread view Subject view Author view Attachment view

From: Thomas Lumley (tlumley@u.washington.edu)
Date: Wed 12 Sep 2001 - 01:20:56 EST


Message-id: <Pine.A41.4.33.0109110815580.62078-100000@homer16.u.washington.edu>

On Mon, 10 Sep 2001 Gerard.Keogh@cso.ie wrote:

> 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?

Actually neither x nor m gets printed from within the function, because
you didn't ask R to print either of them.

The statement
     x
means "Work out what x is". To print x you need
     print(x)
which means "Work out what x is and print the result"

The thing that is printed when you type mm(u) at the command line is not m
but mm(u). At the command line, only, a calculated value that isn't
assigned to any other variable will be printed.

So
   mm(u)
at the command line means "Work out the value of mm(u)", and since it is
at the command line and the result is not assigned to anything it is printed.

        -thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Thu 17 Jan 2002 - 11:10:06 EST