system2(base)
system2()所属R语言包:base
Invoke a System Command
调用系统命令
译者:生物统计家园网 机器人LoveR
描述----------Description----------
system2 invokes the OS command specified by command.
system2command指定调用操作系统命令。
用法----------Usage----------
system2(command, args = character(),
stdout = "", stderr = "", stdin = "", input = NULL,
env = character(),
wait = TRUE, minimized = FALSE, invisible = TRUE)
参数----------Arguments----------
参数:command
the system command to be invoked, as a character string.
要调用系统命令,作为一个字符串。
参数:args
a character vector of arguments to command.
command参数的特征向量。
参数:stdout, stderr
where output to "stdout" or "stderr" should be sent. Possible values are "", to the R console (the default), NULL or FALSE (discard output), TRUE (capture the output in a character vector) or a character string naming a file.
输出“stdout或stderr应发送。可能的值是""的R控制台(默认),NULL或FALSE(抛弃输出),TRUE(捕获的一个特征向量输出)或字符串命名的文件。
参数:stdin
should input be diverted? "" means the default, alternatively a character string naming a file. Ignored if input is supplied.
输入改行? ""意味着默认,或者一个字符串命名的文件。如果input提供被忽略。
参数:input
if a character vector is supplied, this is copied one string per line to a temporary file, and the standard input of command is redirected to the file.
如果提供的特征向量,这是复制一个到一个临时文件,每行字符串,command标准输入重定向到文件。
参数:env
character vector of name=value strings to set environment variables.
字符向量的名称=值字符串来设置环境变量。
参数:wait
a logical (not NA) indicating whether the R interpreter should wait for the command to finish, or run it asynchronously. This will be ignored (and the interpreter will always wait) if stdout = TRUE.
逻辑(不NA)表示的R解释是否应该等待命令完成,或异步运行。这将被忽略(和解释将永远等待)如果stdout = TRUE。
参数:minimized
logical (not NA), indicates whether the command window should be displayed initially as a minimized window.
逻辑(而不是NA),指示是否最初应作为一个最小化的窗口显示命令窗口。
参数:invisible
logical (not NA), indicates whether the command window should be visible on the screen.
逻辑(而不是NA),表示该命令是否窗口应该是在屏幕上可见。
Details
详情----------Details----------
Unlike system, command is always quoted by shQuote, so it must be a single command without arguments.
不像system,command总是shQuote报价,所以它必须是一个单一的命令不带参数。
For details of how command is found see system.
如何command看到system的详细信息。
On Windows, env is currently only supported for commands such as R and make which accept environment variables on their command line.
在Windows中,env目前只支持如R和make接受他们的命令行环境变量的命令。
Some Unix commands (such as ls) change their output depending on whether they think it is redirected: stdout = TRUE uses a pipe whereas stdout = "some_file_name" uses redirection.
一些Unix命令(如ls)改变其输出取决于他们是否认为它被重定向:stdout = TRUE而stdout = "some_file_name"使用重定向使用管道。
Because of the way it is implemented, on a Unix-alike stderr = TRUE implies stdout = TRUE: a warning is given if this is not what was specified.
因为它的方式实施,对一个Unix相似的stderr = TRUE意味着stdout = TRUE:如果这不是什么指定,给予警告。
值----------Value----------
If stdout = TRUE or stderr = TRUE, a character vector giving the output of the command, one line per character string. (Output lines of more than 8095 bytes will be split.) If the command could not be run an R error is generated. If command runs but gives a non-zero exit status this will be reported with a warning.
如果stdout = TRUE或stderr = TRUE,给该命令的输出,字符串每行的字符向量。 (超过8095个字节的输出线将被分割。)如果该命令不能运行一个R会产生错误。 command如果运行,但给出了一个非零的退出状态将报告一个警告。
In other cases, the return value is an error code (0 for success), given the invisible attribute (so needs to be printed explicitly). If the command could not be run for any reason, the value is 127. Otherwise if wait = TRUE the value is the exit status returned by the command, and if wait = FALSE it is 0 (the conventional success value). Some Windows commands return out-of-range status values (e.g. -1) and so only the bottom 16 bits of the value are used.
在其他情况下,返回值是一个错误代码(0成功),由于无形属性(需要明确印)。如果该命令不能运行任何理由,该值是127。否则,如果wait = TRUE值是由命令返回的退出状态,如果wait = FALSE是0(传统的成功值)。有些Windows命令返回范围的状态值(例如-1),所以只有底部16位的值是用来。
注意----------Note----------
system2 is a more portable and flexible interface than system, introduced in R 2.12.0. It allows redirection of output without needing to invoke a shell on Windows, a portable way to set environment variables for the execution of command, and finer control over the redirection of stdout and stderr. Conversely, system (and shell on Windows) allows the invocation of arbitrary command lines.
system2是一个比system更轻便灵活的接口,在R 2.12.0介绍。它允许重定向输出,而无需调用在Windows的外壳,可移植的方式来执行command,并更好地控制stdout和stderr重定向设置的环境变量。相反,system(shell在Windows上)允许任意的命令行调用。
There is no guarantee that if stdout and stderr are both TRUE or the same file that the two streams will be interleaved in order. This depends on both the buffering used by the command and the OS.
有没有保证,如果stdout和stderr都TRUE或相同的文件,为了将交错的两个流。这取决于命令使用的缓冲和操作系统。
参见----------See Also----------
system.
system。
shell and shell.exec.
shell和shell.exec。
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|