[R] r-help:
Ott Toomet
otoomet at econ.dk
Tue Dec 10 10:22:03 CET 2002
Hi,
| From: Sam McClatchie <s.mcclatchie at niwa.co.nz>
| Date: Tue, 10 Dec 2002 10:03:48 +1300
|
| Can anyone tell me what R does with local variables when they are passed
| in a system call to a shell script?
|
| e.g. I have a string as an R variable called tripcode. I want to pass
| this variable in a system call to a local bash script calling gmt
| (Generic Mapping Tool) functions:
|
| system("source map_acoustic_transects_and_trawls.gmt", tripcode)
You are missing paste() here. Look ?paste.
E.g.
a <- "-l"
> system("ls", a)
10-doc funktsioonid.R~ lave-spell Overview.dvi
andmed gauss-analyse.tar.gz lave-spell.tar.gz Overview.log
artikkel2 gauss-analyse.tar.gz~ Leifi_kirjad.txt Overview.tex
...
> system(paste("ls", a))
total 488
drwxrwxr-x 2 otoomet otoomet 4096 dets 5 14:19 10-doc
drwxrwxr-x 3 otoomet otoomet 4096 nov 19 15:46 andmed
drwxrwxr-x 3 otoomet otoomet 4096 dets 5 12:44 artikkel2
drwxrwxr-x 2 otoomet otoomet 4096 dets 5 07:03 bilder
...
| I think this is what is meant in Section 4.6 of Venables and Ripley(?).
|
| When I ECHO the parameter passed into the bash script nothing is returned:
|
| echo "TripCode" $tripcode
| TripCode
|
| Is there a way to do this efficiently without writing the string
| variable to a file and re-reading it into the shell script?
Ott
More information about the R-help
mailing list