[R] Mute script

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 16 08:54:08 CEST 2006


How are you running this 'script'?

If you use source(), you do need to explicitly print or use the 
'print.eval' argument.

If you use R CMD BATCH or similar (which is what most people mean by 
running a script), you do get autoprinting.

On Sun, 15 Oct 2006, Alexandre Aguiar wrote:

> Hi,
>
> I tried to run the following script with R 2.4.0. The data stuff is commented
> out because data are already in memory.
>
> #db <- read.csv("normais.csv", sep=";", quote="", header=T)
> sink("normais-chi.txt", append=T, type = "output", split=T)
> #sink("normais-chi.txt", append=T)
> table(db$agua, db$mBerg)
> chisq.test(db$agua, db$mBerg, correct=F)
> print(table(db$agua, db$mBerg))
> print(chisq.test(db$agua, db$mBerg, correct=F))
> # here there are several other table/chisq.test pairs
> sink()
> #rm(db)
>
> By introducing syntax errors in the script error messages will appear but
> normal output won't neither at screen nor at the sink file.
> On the other hand, by inserting print commands I get both screen and file
> outputs.
> Is it necessary to use the print command in every line? In interactive mode
> the simple command will produce the proper output. Or do I have a
> configuration problem?
>
> Haven't found the answer elsewhere in teh Net.

If as I suspect you used source() the answer is both on the help page and 
in the archives of this list.

-- 
Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list