大的矢量條件I具有大小爲5例如一個矢量:應用 '>' 中,如果用比長度1中的R
a<-c(1,4,6,3,2)
我也有尺寸1的另一向量:
b<-9
我想編寫以下if條件:
if (a>b) { 1
}
else 0
}
我得到以下警告:
Warning message:
In if (fitness_neighbours > user_fitness) { :
the condition has length > 1 and only the first element will be used
我真正喜歡做的是檢查'a'中的任何元素是否滿足條件。