r - How can I find out what proportion of values fall outside range? -
v <- c(1,2,3,4,5,6)
and mention max=4,min=2
so, want know how many values fall outside range.
i can (v < 2 & v > 4)
but not sure how count...
after create percentage respect total number of values (here 6).
you can do:
sum(v < 2 | v > 4) / length(v) [1] 0.5
you want use |
instead of &
because no number both less 2 , greater 4.
Comments
Post a Comment