EVOLUTION-MANAGER
Edit File: rcmd.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Run an R CMD command</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for rcmd {callr}"><tr><td>rcmd {callr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Run an <code style="white-space: pre;">R CMD</code> command</h2> <h3>Description</h3> <p>Run an <code style="white-space: pre;">R CMD</code> command form within R. This will usually start another R process, from a shell script. </p> <h3>Usage</h3> <pre> rcmd( cmd, cmdargs = character(), libpath = .libPaths(), repos = default_repos(), stdout = NULL, stderr = NULL, poll_connection = TRUE, echo = FALSE, show = FALSE, callback = NULL, block_callback = NULL, spinner = show && interactive(), system_profile = FALSE, user_profile = "project", env = rcmd_safe_env(), timeout = Inf, wd = ".", fail_on_status = FALSE, ... ) rcmd_safe( cmd, cmdargs = character(), libpath = .libPaths(), repos = default_repos(), stdout = NULL, stderr = NULL, poll_connection = TRUE, echo = FALSE, show = FALSE, callback = NULL, block_callback = NULL, spinner = show && interactive(), system_profile = FALSE, user_profile = "project", env = rcmd_safe_env(), timeout = Inf, wd = ".", fail_on_status = FALSE, ... ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>cmd</code></td> <td> <p>Command to run. See <code>R --help</code> from the command line for the various commands. In the current version of R (3.2.4) these are: <code>BATCH</code>, <code>COMPILE</code>, <code>SHLIB</code>, <code>INSTALL</code>, <code>REMOVE</code>, <code>build</code>, <code>check</code>, <code>LINK</code>, <code>Rprof</code>, <code>Rdconv</code>, <code>Rd2pdf</code>, <code>Rd2txt</code>, <code>Stangle</code>, <code>Sweave</code>, <code>Rdiff</code>, <code>config</code>, <code>javareconf</code>, <code>rtags</code>.</p> </td></tr> <tr valign="top"><td><code>cmdargs</code></td> <td> <p>Command line arguments.</p> </td></tr> <tr valign="top"><td><code>libpath</code></td> <td> <p>The library path.</p> </td></tr> <tr valign="top"><td><code>repos</code></td> <td> <p>The <code>repos</code> option. If <code>NULL</code>, then no <code>repos</code> option is set. This options is only used if <code>user_profile</code> or <code>system_profile</code> is set <code>FALSE</code>, as it is set using the system or the user profile.</p> </td></tr> <tr valign="top"><td><code>stdout</code></td> <td> <p>Optionally a file name to send the standard output to.</p> </td></tr> <tr valign="top"><td><code>stderr</code></td> <td> <p>Optionally a file name to send the standard error to. It may be the same as <code>stdout</code>, in which case standard error is redirected to standard output. It can also be the special string <code>"2>&1"</code>, in which case standard error will be redirected to standard output.</p> </td></tr> <tr valign="top"><td><code>poll_connection</code></td> <td> <p>Whether to have a control connection to the process. This is used to transmit messages from the subprocess to the parent.</p> </td></tr> <tr valign="top"><td><code>echo</code></td> <td> <p>Whether to echo the complete command run by <code>rcmd</code>.</p> </td></tr> <tr valign="top"><td><code>show</code></td> <td> <p>Logical, whether to show the standard output on the screen while the child process is running. Note that this is independent of the <code>stdout</code> and <code>stderr</code> arguments. The standard error is not shown currently.</p> </td></tr> <tr valign="top"><td><code>callback</code></td> <td> <p>A function to call for each line of the standard output and standard error from the child process. It works together with the <code>show</code> option; i.e. if <code>show = TRUE</code>, and a callback is provided, then the output is shown of the screen, and the callback is also called.</p> </td></tr> <tr valign="top"><td><code>block_callback</code></td> <td> <p>A function to call for each block of the standard output and standard error. This callback is not line oriented, i.e. multiple lines or half a line can be passed to the callback.</p> </td></tr> <tr valign="top"><td><code>spinner</code></td> <td> <p>Whether to show a calming spinner on the screen while the child R session is running. By default it is shown if <code>show = TRUE</code> and the R session is interactive.</p> </td></tr> <tr valign="top"><td><code>system_profile</code></td> <td> <p>Whether to use the system profile file.</p> </td></tr> <tr valign="top"><td><code>user_profile</code></td> <td> <p>Whether to use the user's profile file. If this is <code>"project"</code>, then only the profile from the working directory is used, but the <code>R_PROFILE_USER</code> environment variable and the user level profile are not. See also "Security considerations" below.</p> </td></tr> <tr valign="top"><td><code>env</code></td> <td> <p>Environment variables to set for the child process.</p> </td></tr> <tr valign="top"><td><code>timeout</code></td> <td> <p>Timeout for the function call to finish. It can be a <a href="../../base/html/difftime.html">base::difftime</a> object, or a real number, meaning seconds. If the process does not finish before the timeout period expires, then a <code>system_command_timeout_error</code> error is thrown. <code>Inf</code> means no timeout.</p> </td></tr> <tr valign="top"><td><code>wd</code></td> <td> <p>Working directory to use for running the command. Defaults to the current working directory.</p> </td></tr> <tr valign="top"><td><code>fail_on_status</code></td> <td> <p>Whether to throw an R error if the command returns with a non-zero status code. By default no error is thrown.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Extra arguments are passed to <code><a href="../../processx/html/run.html">processx::run()</a></code>.</p> </td></tr> </table> <h3>Details</h3> <p>Starting from <code>callr</code> 2.0.0, <code>rcmd()</code> has safer defaults, the same as the <code>rcmd_safe()</code> default values. Use <code><a href="rcmd_copycat.html">rcmd_copycat()</a></code> for the old defaults. </p> <h3>Value</h3> <p>A list with the command line <code style="white-space: pre;">$command</code>), standard output (<code style="white-space: pre;">$stdout</code>), standard error (<code>stderr</code>), exit status (<code style="white-space: pre;">$status</code>) of the external <code style="white-space: pre;">R CMD</code> command, and whether a timeout was reached (<code style="white-space: pre;">$timeout</code>). </p> <h3>Security considerations</h3> <p><code>callr</code> makes a copy of the user's <code>.Renviron</code> file and potentially of the local or user <code>.Rprofile</code>, in the session temporary directory. Avoid storing sensitive information such as passwords, in your environment file or your profile, otherwise this information will get scattered in various files, at least temporarily, until the subprocess finishes. You can use the keyring package to avoid passwords in plain files. </p> <h3>See Also</h3> <p>Other R CMD commands: <code><a href="rcmd_bg.html">rcmd_bg</a>()</code>, <code><a href="rcmd_copycat.html">rcmd_copycat</a>()</code> </p> <h3>Examples</h3> <pre> rcmd("config", "CC") </pre> <hr /><div style="text-align: center;">[Package <em>callr</em> version 3.7.2 <a href="00Index.html">Index</a>]</div> </body></html>