get_interpolated_expr | R Documentation |
string_magic
callTool intended for development: use get_interpolated_expr
to obtain the list of expressions
which will be interpolated in a string_magic()
call.
The function get_interpolated_vars
provides the variables instead.
get_interpolated_expr(x, parse = FALSE, delim = c("{", "}"))
get_interpolated_vars(x, delim = c("{", "}"))
x |
A character scalar for which the variables will be recovered.
For example |
parse |
Logical scalar, default is |
delim |
Character vector of length 1 or 2. Default is If of length 1, it must be of the form: 1) the opening delimiter,
2) a single space, 3) the closing delimiter. Ex: [ ]: R:%20 [", "]: R:%22,%20%22 |
Note that this function captures even deeply nested interpolations.
If the argument parse = FALSE
, the default, then this function returns a
character vector containing all the expressions that will be interpolated.
This vector can be empty if there is no interpolation.
If the argument parse = TRUE
, then a list is returned, containing the R expressions.
The function get_interpolated_vars
always return a character vector.
get_interpolated_vars()
: Obtain the variables used in string_magic()
interpolations
String operations: string_is()
, string_get()
, string_clean()
, string_split2df()
.
Chain basic operations with string_ops()
. Clean character vectors efficiently
with string_clean()
.
Use string_vec()
to create simple string vectors.
String interpolation combined with operation chaining: string_magic()
. You can change string_magic
default values with string_magic_alias()
and add custom operations with string_magic_register_fun()
.
Display messages while benefiting from string_magic
interpolation with cat_magic()
and message_magic()
.
Other tools with aliases:
cat_magic_alias()
,
string_magic()
,
string_magic_alias()
,
string_ops_alias()
,
string_vec_alias()
# let's create a simple interpolation
x = c("Ken", "Barbie")
sma_expr = "{' loves 'c ? x}. But does {' love 'c ? rev(x)}?"
string_magic(sma_expr)
# We recover the two expressions
(char = get_interpolated_expr(sma_expr))
# same with parsing
(expr = get_interpolated_expr(sma_expr, parse = TRUE))
# see the difference
eval(char[[1]])
eval(expr[[1]])
# and only the variables:
get_interpolated_vars(sma_expr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.