mercredi 22 septembre 2021

How to find out how many numbers in my vector is lower than a given number

I want to find out how many numbers in my vector are lower than a given value. I came up with this code but get the following warning message. I've tried different things like comparing vectors of the same size etc. but nothing seems to work.

test.seq <- seq(from = 20000, to = 0, length.out = 100) 
n.lower <- matrix(0, nrow = 1, ncol = 1)
for(i in 1:100){
   if(test.seq < 10000){
      n.lower <- n.lower + 1
   }
}

Warning message:
In if (test.seq < 1000) { :
  the condition has length > 1 and only the first element will be used

Thanks!

Aucun commentaire:

Enregistrer un commentaire