[英]Error in setting bin grouping using cut Error in if (d2 == 0L) { : missing value where TRUE/FALSE needed
I try to group my dataset to different bin size with the function cut, 我尝试使用函数cut将我的数据集分组到不同的bin大小,
cuts <- apply(rd, 4, cut, c(-Inf, seq(10, 80, 10), Inf), labels=10:90)
but this error pops out: 但是这个错误弹出:
Error in if (d2 == 0L) { : missing value where TRUE/FALSE needed
if(d2 == 0L){:缺少值需要TRUE / FALSE时出错
I guess it's because some of my value just matches the cutoff value, can anyone please teach me how to modify my code so that if it matches it will go to the group >=
the value?? 我想这是因为我的一些价值恰好与截止值相匹配,任何人都可以教我如何修改我的代码,这样如果它匹配它将转到组
>=
值?
If we are using cut
on the 4th column 如果我们在第4列使用
cut
cut(rd[,4], breaks= c(-Inf, seq(10, 80, 10), Inf), labels=10:90)
The apply
methods are used for matrices with > one dimension. apply
方法用于具有>一维的矩阵。 Here, we are only using the 4th column, so the function can be directly applied on the vector
. 这里,我们只使用第4列,因此该函数可以直接应用于
vector
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.