[R] Using system() to dump HDF to text file?
wdunlap at tibco.com
Tue Jan 15 20:21:52 CET 2013
Use shell() instead of system(). E.g., I have a bunch of Unix-like
executables in c:\cygwin\bin and I can use pipe and redirection
signs with them using shell():
> tf <- tempfile()
> shell(paste("c:\\cygwin\\bin\\ls | c:\\cygwin\\bin\\head -5 >", shQuote(tf, "cmd")))
 "R.dll" "R.exe" "RSetReg.exe" "Rblas.dll" "Rcmd.exe"
 "C:/Program Files/R/R-2.15.2/bin/x64"
 "open.exe" "R.dll" "R.exe" "Rblas.dll" "Rcmd.exe" "Rgraphapp.dll" "Rgui.exe" "Riconv.dll" "Rlapack.dll" "Rscript.exe" "RSetReg.exe"
 "Rterm.exe" "Rzlib.dll"
Spotfire, TIBCO Software
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Sarah Henderson
> Sent: Tuesday, January 15, 2013 10:28 AM
> To: R List
> Subject: [R] Using system() to dump HDF to text file?
> Hi all --
> I am working on 64-bit Windows XP. I'm not a very technical person when it
> comes to the command line stuff, so please forgive me if this is a stupid
> I have a bunch of HDF files, and I want to dump a single PM25 data layer
> from each file to .txt by invoking ncdump.exe from system(). Here's a
> sample command string:
> "C:/ncdump -v PM25 C:/01aug2010.hdf > C:/01aug2010.txt"
> This works perfectly in Python, but does not actually generate the .txt
> file in R when:
> It does show the output on the console, if flagged to do so, and I can
> capture the output to an R object with intern = T. I assume there is some
> problem with the way I have specified how to get the output to the text
> file (i.e. the ">"), but experimentation with other options has not gone
> Can anyone advise?
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help