Answers for "how to group rages in r"

0

how to group rages in r

df <- data.frame(name=c("r", "h", "s", "l", "e", "m"), value=c(35,20,16,40,23,40))
# get categories
df$groups <- cut(df$value, breaks=c(0,21,30,Inf))

# calculate group counts:
table(cut(df$value, breaks=c(0,21,30,Inf)))
Posted by: Guest on July-13-2021

Browse Popular Code Answers by Language