This help topic is for R version 1.5.0. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/system.html
system {base}R Documentation

Invoke a System X Command from Carbon R

Description

system invokes the OS X shell commands specified by command.

Usage

system(command,intern=FALSE)

Arguments

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.

Details

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.

Value

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.

Examples

# 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") 

[Package base version 1.5.0 ]