sum <- function(data){
sum(data)
}
median <- function(data){
median(data)
}
floor <- function(data){
floor(data)
}
evaluate <- function(func, dat){
func(dat)
}
这是我的代码。我想要实现的目标如下:
评估(总和,c(2,4,6))应评估为12;
评估(中位数,c(7,40,9))应评估为9;
但我总是得到如下错误
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
Error during wrapup: evaluation nested too deeply: infinite recursion / options(expressions=)?
答案 0 :(得分:-1)
代码应为
eval <- function(func, num){
return(func(num))
}
x <- eval(floor, 11.1)
> x
[1] 11