I have a data frame with the string "BLQ" in some of the cells. I can find out where these occur using:
which(df == "BLQ", arr.ind = TRUE)
In a particular example I am interested in, the length of the vector above yields
> length(which(df == "BLQ", arr.ind = TRUE))
[1] 492
If I execute the following:
which(df == "BLQ", arr.ind = TRUE)
stop("BLQ still present")
I will see all entries (rows and columns) where "BLQ" occurs and the program stops with the desired output:
Error: BLQ still present
But if I have the above enclosed in an IF statement:
if (length(which(df == "BLQ", arr.ind = TRUE)) != 0){
which(df == "BLQ", arr.ind = TRUE)
stop("BLQ still present")
}
The output from the which function is suppressed and I just see:
Error: BLQ still present
Why is that?
Thank you for your help.