I run this code to see if in depth I have "0-5cm", it works but I also get a warning message that I don’t understand, anyone know?
if (isTRUE(!any(depth) %in% "0-5cm")) {print("yes")} else {print("no")}
[1] "yes"
Warning message:
In any(depth) : coercing argument of type 'character' to logical
>Solution :
You are mixing up your parenthesis.
If you want to asses your if condition you need something more like:
if(!any(depth %in% "0-5cm")) # looking for the many in the specific makes logically little sense, even if it works
Also not knowing how depth looks like, i assume it is a vector?
If this is the case I’d advise to turn your statement around to:
!any("0-5cm" %in% depth) # looking for the specific within the many