Description Usage Arguments Details Value Examples
Assign an alias to an R expression in the interactive console.
This package provides the ability to create shortcuts for use in the interactive R console to prevent yourself from writing commonly used expressions multiple times.
1 2 3 4 |
... |
The named arguments will be translated to the aliases. See the accompanying examples. |
envir |
environment. The environment to bind the aliases in using
|
register |
logical. Whether or not to register the shortcut
in the registry. By default, |
expression_names |
character. The expressions to unmap. |
deregister |
logical. Whether or not to deregister the shortcut
in the registry. By default, |
For example, if you frequently find yourself typing
some_annoyingly$long_expression
,
you can bind it to S
by writing
mappy(S = some_annoyingly$long_expression)
.
Now, typing S
in your interactive R console executes the expression
in full each time. Note that mappy relies on the ~/.R/mappy file to make
this work between sessions. If you wish to use a different file, set
options(mappy.file = "/your/dir/file")
.
Mappy shortcuts do not apply outside of interactive R sessions (see
interactive
.
the names of the bound shortcuts.
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## Not run:
mappy(hi = cat("Hello world"))
hi # Now, writing "hi" executes cat("Hello world")
stopifnot(bindingIsActive("hi", globalenv()))
unmappy("hi") # Now the shortcut is gone.
## End(Not run)
env <- new.env()
mappy(m = lm(Sepal.Width ~ Sepal.Length, data = iris)$model, envir = env)
# Now, env$m will refer to the lm model object. Note that since the
# expression will be re-computed each time, so will the model!
model <- env$m
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.