Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.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_While Loop_Iteration - Fatal编程技术网

R 如何测试迭代是否无限运行?

R 如何测试迭代是否无限运行?,r,while-loop,iteration,R,While Loop,Iteration,晚上好, 我想使用R和以下代码进行迭代: a<- 2 f <- function(x){ x <-1 f <- a*x x <- f } #function is hereby defined # iterations while (x<3){ f } 当您将函数名定义为f,然后在a*x中的函数赋值f时,aIt不清楚,这里有许多问题。您正在定义一个函数f,该函数接受输入x,但随后总是设置x

晚上好,

我想使用R和以下代码进行迭代:

a<- 2
f <- function(x){
  x <-1
  f <- a*x
  x <- f
}  #function is hereby defined

# iterations
while (x<3){
  f
}


当您将函数名定义为
f
,然后在
a*x
中的函数赋值
f
时,
aIt不清楚,这里有许多问题。您正在定义一个函数
f
,该函数接受输入
x
,但随后总是设置
x