0

I would find a fast way to get a count of values in specific column that match some conditions and then produce a summary table for each condition.

Specifically, let's say this is my df:

df <- data.frame(X = sample(1:100))

To know how many observations are less than 25, between 25 and 50 and greater than 50 I simply use count function:

count(df, df$X <25)
count(df, df$X >=25 & df$X <=50)
count(df, df$X > 50)

I was just wondering, if there is a way to get the same results in a more efficient way, and maybe in table format, something like this:

<25     24
25-50   26
>50     50

Thanks in advance for any suggestion.

Ramon_88
  • 109
  • 11

0 Answers0