# [R] Finding if numbers fall within a range

Eliza Botto e||z@_botto @end|ng |rom out|ook@com
Sat Aug 28 17:57:09 CEST 2021

```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 are to be reserved are;

0-60, 61-120, 121-180, 181-240, 241-300, 301-360

In row 1, the number "1", "57", and "59" fall 2ith the range 0-60. Whereas "271" and "279" falls within the range 241-300. So in total 2 ranges are covered and coding should execute 2 for row one.

In row 2, the number "59" falls in the range 0-60, "179" falls in the range 121-180, "279" and "278" fall within the range 241-300, and 359 falls in the range 301-360. In total 4 ranges are covered for row 2.

In the like-wise pattern, 5 ranges are covered in row 3.

So, what I want is a matrix that looks in the following

> dput(EBI)

structure(c(2, 4, 5), .Dim = c(3L, 1L))

Is there an easy way of doing it?

I thank you all very much in advance

EB

[[alternative HTML version deleted]]

```