[R] Redirecting output to the screen

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Mar 15 17:14:44 CET 2007


This is much easier in R-devel: just use message() and scan("stdin").

gannet% cat Test.R
message("Enter file name: ", appendLF=FALSE)
fn <- scan("stdin", what="", n=1)

works for me in R-devel via  R --vanilla -f Test.R > Rout.txt
I believe it also works under Windows.

On Wed, 14 Mar 2007, John Schuenemeyer wrote:

> A simple example follows.  The file is called Test.R
> # Example
> rm(list=is(all=TRUE))
> cat("Enter file name")
> fn<-scan(what="")
>
> I execute the following:
> @C:\PROGRA~1\R\R-2.4.1\bin\Rterm.exe --no-restore --no-save < Test.R > Rout.txt
>
> I do not see the "Enter file name" or have the opportunity to enter the file name.  I am running R in windows XP.
>
> Thanks for your help.
>
> John H Schuenemeyer
> Southwest Statistical Consulting, LLC
> 960 Sligo St
> Cortez, CO 81321-2558
>
> Phone: 970.565.0179
>
> URL: www.swstatconsult.com
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.

PLEASE do, and not send HTML.

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