Re: [R] Defining and running a simple function

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu 02 Feb 2006 - 18:17:00 EST

Placing a variable on a line by itself only invokes print if you type it in from the console. In a function you must use an explicit print.

On 2/2/06, Thomas L Jones <DrJones@alum.mit.edu> wrote:
> I am trying, with extremely limited success, to get the R software to
> do some simple computations. Specifically, I defined a test function
> as follows:
>
> fn <- function () {
>
> hw <- "hello world"
>
> hw
>
> s <- seq (0, 0.98, 0.02)
>
> s
>
> }
>
> The output should just be the words "hello world," followed by a
> sequence going from 0 to 0.98.
>
> However, when I call the little test function:
>
> fn ()
>
> the words "hello world" get lost and do not come out. Instead, the
> output begins with
>
> [1] 0.00 0.02, etc
>
> However, when I write a test function for just the words "hello
> world," the words come out just fine.
>
> Here is the setup:
>
> R-2.2.0 using the English language and the console
> Windows XP Home Edition Service Pack 2
> AVG Antivirus Free Version
> Windows built-in firewall
> The R buffered output is disabled.
> Mozilla Firefox 1.5
> Administrator privileges are enabled.
>
> Your advice?
>
> Tom Jones
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Feb 02 18:24:21 2006

This archive was generated by hypermail 2.1.8 : Thu 02 Feb 2006 - 20:22:50 EST