Description Usage Arguments Value Examples
Replace top level assignments
1 | replace_top_level_assignments(code, from_func, to_func)
|
code |
list of expressions to modify or quoted code block |
from_func |
a function accepting a single argument, the top level
expression, which will return |
to_func |
a function accepting a single argument, the expression being assigned to, defining how a top level assignment expression should be modified |
modified code block as a list of top level expressions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | q <- quote({
a <- list()
a$first <- "1st!"
untouched <- 1
a$second <- "2nd!"
untouched <- 2
a
})
scriptgloss:::replace_top_level_assignments(
q,
function(i) is.call(i) && length(i) >= 3 && i[[1]] == quote(a$a)[[1]],
function(i) as.name(sprintf(
"__%s__%s__",
as.character(i[[2]]),
as.character(i[[3]])))
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.