Let say I’ve a data frame consists of one variable (x)
df <- data.frame(x=c(1,2,3,3,5,6,7,8,9,9,4,4)) I want to know how many numbers are less than 2,3,4,5,6,7. I know how to do this manually using
# This will tell you how many numbers in df less than 4 xnew <- length(df[ which(df$x < 4), ]) My question is how can I automate this by using for-loop or other method(s)? And I need to store the results in an array as follows
i length 2 1 3 2 4 4 5 6 6 7 7 8 Thanks