Getting functions from a character string
In Burn R Inferno , p. 65, you can find the following code:
funs <- c(’mean’, ’median’)
eval(as.name(funs[2]))(data)
However, for me this generates:
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
'x' must be atomic
In addition: Warning message:
In is.na(x) : is.na() applied to non-(list or vector) of type 'closure'
What am I doing wrong? Is this a mistake / typo in the book?
+3
source to share
No one has answered this question yet
Check out similar questions: