From thomas@biostat.washington.edu  Fri Oct 17 17:08:45 1997
From: thomas@biostat.washington.edu (Thomas Lumley)
Date: Fri, 17 Oct 1997 09:08:45 -0700 (PDT)
Subject: R-alpha: system() NOT ok
In-Reply-To: <97Oct17.115143edt.26514@mailgate.bank-banque-canada.ca>
Message-ID: <Pine.SUN.3.95.971017090227.10996A-100000@troi>

On Fri, 17 Oct 1997, Paul Gilbert wrote:

> Why does parse not work below and why does assigning it crash R?
> 
> Paul
> ________
> $ R
> R : Copyright 1997, Robert Gentleman and Ross Ihaka
> Version 0.50 Alpha-3 (August 8, 1997)
> 
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type "license()" for details.
> 
> > system("date \'+%Y %m %d %H %M %S\'", intern=T)
> [1] "1997 10 17 11 43 21"
> > parse(text = system("date \'+%Y %m %d %H %M %S\'", intern=T),white =
> T)
> 1997 10 17 11 43 43
>       ^

It doesn't work because space-separated lists of numbers aren't valid R
syntax. You can use 
  >parse(text=strsplit( system("date \'+%Y %m %d %H %M %S\'",
intern=T)," ")[[1]])
 expression(1997, 10, 17, 9, 7, 8)

where strsplit(a,b) splits string a at character b.

	
The crash is a known bug and happens whenever you assign the result of a
syntax error in the parser.


Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

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


R-alpha: system() NOT ok
Thomas Lumley