Count observations greater than a particular value [duplicate]
Solution 1:
Try using logical test and then sum over the values meeting the condition
sum(output$V4 > 2000)
Solution 2:
if using a data.frame you could also use:
nrow(output[output$V4>2000, ])
Solution 3:
As already mentioned above this is easier than people often realise:
Inputting "output$V4 >2000" will test which values are >2000 and output TRUE or FALSE, as > is a logical comparison
As a result you can SUM over this to find the number of values which are TRUE (>2000), ie Count. While you may have been expecting this input to SUM the actual values themselves