I am trying to create an if statement with the condition "if any numbers in the column [,1] of Matrix B are greater than 4 do this......"
I am unsure of how to check the whole column.
So far I have managed to find out whether it is true or false by doing this:
B[,1] > 4
and it comes back with:
FALSE TRUE TRUE TRUE
I want to make it so if at least one statement came back as "TRUE" it would carry out the 'if' statement:
if ((B[,1] > 4) == TRUE){
Move <- append(Move, 5)
}
This comes up with the Warning message:
In if ((B[, 1] > 4) == TRUE) Move :
the condition has length > 1 and only the first element will be used
How should I code it to check all the values in the column? I hope I have made my problem clear and any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire