Re: [R] Finding if numbers fall within a range

2021-08-29 Thread Eliza Botto
Thanks Jeff, It worked!! From: Jeff Newmiller Sent: Saturday 28 August 2021 16:32 To: r-help@r-project.org ; Eliza Botto ; r-help@r-project.org Subject: Re: [R] Finding if numbers fall within a range You messed up the dput somehow... but I think this works: m

Re: [R] Finding if numbers fall within a range

2021-08-28 Thread Jeff Newmiller
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)

Re: [R] Finding if numbers fall within a range

2021-08-28 Thread Andrew Simmons
Hello, I think I've found a solution, but it's not producing the same answer as what you're expecting. I think you might've mixed up row and column a few times, but you should be able to alter the following to your needs. Also, see ?.bincode: EB <- matrix(data = c( 1, 271, 179, 359, 178,

[R] Finding if numbers fall within a range

2021-08-28 Thread Eliza Botto
Dear useRs, Is there a way in R to see if the numbers in a matrix-row fall within the given range or not? For example, I have the following data; > dput(EB) structure(c(1, 57, 59, 271, 279, 59, 179, 279, 278, 359, 52, 118, 178, 239, 334), .Dim = c(3L, 5L)) The ranges for which these numbers ar