Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何创建范围为R的函数?_R_Function_Range - Fatal编程技术网

如何创建范围为R的函数?

如何创建范围为R的函数?,r,function,range,R,Function,Range,我想定义函数f(x)=(2/pi)*sqrt(1-(x^2))及其范围[-1,1]。我认为R中没有指示符函数,但是我如何定义这个范围呢?这种函数定义呢 f <- function(x) { stopifnot(abs(x)<=1) (2/pi) * sqrt(1-(x^2)) } f

我想定义函数
f(x)=(2/pi)*sqrt(1-(x^2))
及其范围
[-1,1]
。我认为R中没有指示符函数,但是我如何定义这个范围呢?

这种函数定义呢

f <- function(x) {
  stopifnot(abs(x)<=1)
  (2/pi) * sqrt(1-(x^2))
}
f