Command {Rcmdr} | R Documentation |
Compose R Commands from Character Strings
Description
Command
simplifies the process of composing text-string versions of R commands, suitable, e.g., for doItAndPrint
, from character strings representing a function name, arguments to the function, and (optionally) the name of a variable to be assigned the value returned by the function; all of the arguments to Command
are text strings.
Usage
Command(fun, ..., to)
Q(string)
Arguments
fun |
character string representing the name of a function to be called; e.g., |
... |
zero or more named or unnamed arguments for the function; e.g. (for |
to |
optionally the text name of variable to be assigned the value returned by the function; e.g. (for the |
string |
a character string (or an object that can be coerced to a character string). |
Value
Command
returns the text representation of an R command, e.g., "model1 <- lm(y ~ x1 + x2, data=Dataset"
; Q
places quotation marks around string
, e.g., Q("Annual Income")
, and is meant to be used when an argument to Command
should be quoted (see the last example below).
Author(s)
John Fox
See Also
doItAndPrint
, justDoIt
, logger
.
Examples
Command("lm", "prestige ~ income + education", data="Duncan", weights="imp", to="model")
Command("lm", "prestige ~ income + education", data="Duncan", weights=NULL, to="model")
Command("plot", x="income", y="prestige", xlab=Q("Income"), ylab=Q("Prestige"))