Counting observations greater than a certain value

I have a set of data outputin the variable R V1, V2, V3, V4. How can I get the number of observations in V4that area of ​​more than 2000?

+4
source share
3 answers

Try using a logical test, and then summarize the values ​​that match the condition

sum(output$V4 > 2000)
+12
source

if you use data.frame you can also use:

nrow(output[output$V4>2000, ])

+2
source

, , :

"output $V4 > 2000" , > 2000 TRUE FALSE, a > -

As a result, you can use SUM to do this to find the number of TRUE values ​​(> 2000), i.e. Count Although you might have expected that this input for SUM to the actual values ​​themselves

0
source

Source: https://habr.com/ru/post/1533747/


All Articles