Redirect system2 stdout to a file on windows
Works for me (Win 7 64bit) using R.exe:
setwd(tempdir()) getwd()
[1] "C:/Users/hb/AppData/Local/Temp/RtmpSqjCDt"
res <- system2("whoami", stdout="out.txt", stderr="err.txt")
res
[1] 0
file.info(c("out.txt", "err.txt"))
size isdir mode mtime ctime
out.txt 12 FALSE 666 2013-07-15 00:02:06 2013-07-15 00:02:02
err.txt 0 FALSE 666 2013-07-15 00:02:06 2013-07-15 00:02:02
atime exe
out.txt 2013-07-15 00:02:02 no
err.txt 2013-07-15 00:02:02 no
sessionInfo()
R version 3.0.1 Patched (2013-07-10 r63264) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_3.0.1 /Henrik On Mon, Jul 15, 2013 at 12:01 AM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
On Sun, Jul 14, 2013 at 5:20 PM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu> wrote:
On Sun, Jul 14, 2013 at 10:24 PM, Gabor Grothendieck wrote:
Try:
out.txt <- normalizePath("./out.txt", mustWork = FALSE)
Doesn't work either, neither on Win7 nor WinXP.
sessionInfo()
R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit)
Not sure what happened but I tried it again and it did not work on my
system either.
If a workaround is ok then this works on my system:
shell(paste("whoami", ">", "out.txt"))
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel