【发布时间】:2022-12-02 01:10:03
【问题描述】:
I have a long list of random numbers between 1 and 100, and i would like to count how many of them are larger than 10,20,30 etc
x <- c(sample(1:100, 500, replace = T))
y <- seq(0,100, by = 10)
I am looking for this to return an output such as;
| Total | 10 | 20 | 30 | 40 | 50 |
|---|---|---|---|---|---|
| Count | 7 | 13 | 17 | 28 | 42 |
Where Count is the number of x Values that are larger than Total (each y value )
So far, I have tried
Count = ifelse(x > y, 1, 0)
However this returns a list of Binary 1,0 returns for each of the 500 values of X
I'd appreciate any help
【问题讨论】:
标签: r