system {base} | R Documentation |
system
invokes the OS X shell commands specified by command
.
system(command,intern=FALSE)
command |
the system command to be invoked, as a string. |
intern |
a logical, indicates whether to make the output of the command an R object. |
If intern
is TRUE
then the BSD popen
function is used to
invoke the command and the output collected, line by line, into an R
character
vector which is returned as the value of
system
.
If intern
is FALSE
then the output of the command is
redirected directly to the R Console for a maximum of 24k.
This is an experimental and very limited code. It only works when Carbon R is running under MacOS X.
If intern=TRUE
, a character vector giving the output of the
command, one line per character string. If the command could not be
run or gives an error a R error is generated.
If intern=FALSE
, the output of the command is sent directly to the
R Console.
# list all files in the current directory using the -al flag
system("ls -al")
t1 <- system("who",intern=TRUE)
t1
system("ls fizzlipuzzli")# empty since file doesn't exist
system("less AUTHORS")