您可以使用
eval
和
parse
:
eval(parse(text = paste0("ggplot2::", test)))
#function (x, y, ...)
#{
# exprs <- rlang::enquos(x = x, y = y, ...)
# is_missing <- vapply(exprs, rlang::quo_is_missing, logical(1))
# aes <- new_aes(exprs[!is_missing], env = parent.frame())
# rename_aes(aes)
#}
#<bytecode: 0x000001458db09718>
#<environment: namespace:ggplot2
你可以用
match.func
如果你已经加载了
ggplot2
match.fun(test)
#function (x, y, ...)
#{
# exprs <- rlang::enquos(x = x, y = y, ...)
# is_missing <- vapply(exprs, rlang::quo_is_missing, logical(1))
# aes <- new_aes(exprs[!is_missing], env = parent.frame())
# rename_aes(aes)
#}
#<bytecode: 0x000001458db09718>
#<environment: namespace:ggplot2>