[R] 'Rscript -e' and stdout() puzzle

William Dunlap wdunlap at tibco.com
Fri Jun 24 03:28:36 CEST 2011


> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Benjamin Tyner
> Sent: Thursday, June 23, 2011 5:31 PM
> To: r-help at r-project.org
> Subject: [R] 'Rscript -e' and stdout() puzzle
> 
> Hello,
> 
> I am curious to know why the output of
> 
>     Rscript -e "cat(R.version.string,stdout())"
> 
> includes a trailing " 1", whereas
> 
>     Rscript -e "cat(R.version.string)"

Use file=stdout().  Otherwise it prints the value of
as.character(stdout()), which is 1.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> 
> does not. I have tried various mechanisms to subvert this 
> behavior, such as
> 
>     Rscript -e "invisible(con<-stdout()); cat(R.version.string, con);
>     rm(con); q()"
> 
> but the trailing " 1" remains.
> 
> Thanks,
> Ben
> 
> 
> 



More information about the R-help mailing list