Re: t.test inside function (PR#373)

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: t.test inside function (PR#373)
From: Prof Brian D Ripley (ripley@stats.ox.ac.uk)
Date: Mon 13 Dec 1999 - 19:14:28 EST


Message-ID: <Pine.GSO.4.05.9912130911290.20472-100000@auk.stats>

On Mon, 13 Dec 1999 wsi@gcal.ac.uk wrote:

> Full_Name: Bill Simpson
> Version: 65.1
> OS: linux
> Submission from: (NULL) (193.62.250.209)
>
>
> Try this code as separate lines entered interactively, then try doit()
>
> doit<-function()
> {
> x<-seq(1,10)
> y1<-x+rnorm(10,1,1.5)
> y2<-x+rnorm(10,1,1)
> t.test(x,y1,paired=TRUE)
> t.test(x,y2,paired=TRUE)
> }
>
> doit() apparently executes only the last of a series of t.test()s.
>
> Maybe this is no bug, but I can't see why this behaviour is shown.

You need to print the answer: the last is printed by auto-printing.
More generally, if you want something printed in a function, you
need to print it explicitly. This applies to braced expressions too,
so

{
x<-seq(1,10)
y1<-x+rnorm(10,1,1.5)
y2<-x+rnorm(10,1,1)
t.test(x,y1,paired=TRUE)
t.test(x,y2,paired=TRUE)
}

shows the effect.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:11 EST