h <- function(x)
{
if(0 <= x & x<= 0.5)
h = 1 + x/10
if(0.5 <= x & x<= 1)
h = -1 + x/10
return(h)
}
定义了一个简单的分段函数h
h((U[i]))总是报错,大概是因为函数h只能接收数字作为自变量,比如h(0.9)就可以,a = 0.9, h(a)输出就输出一整个函数。我想得到一个具体的数应该怎么做啊。as.numeric(h(a))的话报错cannot coerce type 'closure' to vector of type 'double'