#
#
findUsedOptions =
function(code, asNodes = FALSE)
{
code = to_ast(code)
idx = find_nodes(code, isUsedOption)
if(asNodes)
idx
else
sapply(idx, getUsedOptionName)
}
isUsedOption =
function(node)
{
is(node, "Call") && is(node$fn, "Symbol") && ((node$fn$value == "getOption" || (node$fn$value == "options" && length(node$args) > 0)) ) ||
(node$fn$value %in% c("$", "[[", "[") && length(node$args$contents) > 0 && is(node$args$contents[[1]], "Call") && is(node$args$contents[[1]]$fn, "Symbol") && node$args$contents[[1]]$fn$value == "options")
}
getUsedOptionName =
function(node)
{
if(node$fn$value %in% c("options", "getOption")) {
els = node$args$contents
} else if(node$fn$name == "$") { # must be options()$... or [[...]] or [
return(node$args[[2]]$name)
} else # [[ or [
els = node$args[ - 1 ]
w = sapply(els, is, "Character")
sapply(els[w], function(x) x$value)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.