23 R: Function as a String
23.1 Function as a character/string
23.2 Data
Code
A = c(NA, 12, 15, 14, 18)
23.3 Function call: Option 1
23.4 Function call: Option 2
Code
fn_call = function(f, arg, ...) get(f)(arg, ...)
fn_call("fn_Mean", A, na.rm = T)
$n
[1] 4
$AM
[1] 14.75
$GM
[1] 14.5938
$HM
[1] 14.44126
Code
fn_call("sd", A, na.rm = T)
[1] 2.5