对于这个小难题的任何帮助将不胜感激。
我正在尝试向tq_transmute
函数从tidyquant
包裹;参数的值是一个函数,但是我想将其作为字符串传递(在下面示例的范围内,我将通过 Shiny 传递它)selectInput
).
我已经尝试了所有我能想到的方法将字符串“apply.quarterly”转换为对象apply.quarterly
接受的mutate_fun
争论。注释行是我失败的尝试。
最终,我想将这个概念扩展到其他论点,即FUN = max
to FUN = ‘max’
.
library(tidyverse)
library(tidyquant)
library(rlang)
FANG %>%
group_by(symbol) %>%
tq_transmute(select = adjusted,
mutate_fun = apply.quarterly,
# mutate_fun = sym('apply.quarterly'),
# mutate_fun = syms('apply.quarterly'),
# mutate_fun = !!sym('apply.quarterly'),
# mutate_fun = !!!sym('apply.quarterly'),
# mutate_fun = eval(parse('apply.quarterly')),
# mutate_fun = eval(substitute('apply.quarterly')),
# mutate_fun = enquo('apply.quarterly'),
# mutate_fun = expr(!!enquo('apply.quarterly')),
# mutate_fun = quo('apply.quarterly'),
# mutate_fun = enquos('apply.quarterly'),
# mutate_fun = enquote('apply.quarterly'),
# mutate_fun = quote('apply.quarterly'),
# mutate_fun = substitute('apply.quarterly'),
# mutate_fun = parse('apply.quarterly'),
# mutate_fun = parse('apply.quarterly'),
# mutate_fun = ensym('apply.quarterly'),
# mutate_fun = rlang::as_function('apply.quarterly'),
# mutate_fun = rlang::as_closure('apply.quarterly'),
# mutate_fun = rlang::as_quosure('apply.quarterly'),
# mutate_fun = rlang::as_quosure('apply.quarterly'),
# mutate_fun = enexpr('apply.quarterly'),
# mutate_fun = enexprs('apply.quarterly'),
# mutate_fun = ensym('apply.quarterly'),
# mutate_fun = ensyms('apply.quarterly'),
# mutate_fun = eval_tidy('apply.quarterly'),
# mutate_fun = exprs('apply.quarterly'),
# mutate_fun = expr_deparse('apply.quarterly'),
# mutate_fun = expr_label('apply.quarterly'),
# mutate_fun = expr_label(substitute('apply.quarterly')),
# mutate_fun = expr_label(quote('apply.quarterly')),
# mutate_fun = parse_expr('apply.quarterly'),
# mutate_fun = quasiquotation('apply.quarterly'),
# mutate_fun = quotation('apply.quarterly'),
# mutate_fun = quotation('apply.quarterly'),
FUN = max,
col_rename = "max.close")