简体   繁体   中英

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,

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

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

cut(rd[,4], breaks= c(-Inf, seq(10, 80, 10), Inf), labels=10:90)

The apply methods are used for matrices with > one dimension. Here, we are only using the 4th column, so the function can be directly applied on the vector .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM