[R] help with function "system" and MS-DOS command TYPE
Chen, Xiao
jingy1 at ucla.edu
Wed Jan 31 18:39:45 CET 2007
Dear R-Help,
Thanks much.
I have received very good advice from a couple of experts. R-help is
just wonderful!
I have combined all the solutions that I got and they are shown below:
zz<-file("d:/work/test/test.txt", "w")
cat("this is a test\n", file=zz)
close(zz)
setwd("d:/work/test")
shell("type test.txt")
system("cat test.txt", show.output.on.console=T)
file.show("d:/work/test/test.txt") #opens a new window
file.show("d:/work/test/test.txt", pager="console") #displays on console
Thanks again for all the help.
Best regards,
Xiao Chen
Statistical Consulting Group
UCLA Academic Technology Services
http://www.ats.ucla.edu/stat/
-----Original Message-----
From: Chen, Xiao
Sent: Tuesday, January 30, 2007 8:23 PM
To: 'r-help at stat.math.ethz.ch'
Subject: help with function "system" and MS-DOS command TYPE
Greetings -
I have a quick question that I hope someone will have a quick answer. I
have tried to use the R function "system" with the MS-DOS command "type"
to display the full content of a text file. But it always returns with a
message saying the text file is not found. I could accomplish the same
task with the "cat" command which is one of the unix-like commands that
I have installed on my windows machine. But I would like to know how it
would work with the "type" command.
Here is what I have tried:
> zz<-file("d:/work/test/test.txt", "w")
> cat("this is a test\n", file=zz)
> close(zz)
> system("cat test.txt", show.output.on.console=T)
this is a test
> system("type test.txt", show.output.on.console=T)
test.txt not found
>
Thanks much for any help that you could offer.
Best,
Xiao Chen
Statistical Consulting Group
UCLA Academic Technology Services
http://www.ats.ucla.edu/stat/
More information about the R-help
mailing list