mardi 28 août 2018

R if statement with condition >1 length error

I'm trying to run an if statement, where I want to run something IF any of 23 values is below a certain value.

   test.df<-as.data.frame(c(1:50))
   if (test.df[,c(27:50)] <30){ print("hi")}

I get the error that the condition has length > 1 and only the first element will be used. Which is true... Does anyone know how I can test this if statement for 23 values, whithout having to type them one by one?

Thanks!

Aucun commentaire:

Enregistrer un commentaire