Skip to content
Prev 388921 / 398506 Next

Finding if numbers fall within a range

You messed up the dput somehow... but I think this works:

m <- t(structure(c(1, 57, 59, 271, 279, 59, 179, 279, 278, 359, 52,
118, 178, 239, 334), .Dim = c(5L, 3L)))
brk <- c( 0, 60, 120, 180, 240, 300 )
mc <- matrix( findInterval( m, brk ), ncol = ncol(m) )

m
mc

DBI <- apply( mc, 1, function(v) length( unique( v ) ) )
On August 28, 2021 8:57:09 AM PDT, Eliza Botto <eliza_botto at outlook.com> wrote: