I am trying to run a code where I find the first 10 items in a column of a data set where it displays "Investigation complete" and runs it under the vector "abcd". (I am using a WHILE loop and an IF statement)
I have used this code:
abcd <- NULL x <- 1 while (length(abcd) < 10 ) {
- if(crimes[x, 8] == "Investigation complete") {
- abcd <- c(abcd, crimes[x,1])
- }
- x <- x+1
- }
But after executing this code, i get this error:
Error in if (crimes[x, 8] == "Investigation complete") { : missing value where TRUE/FALSE needed
How can i resolve this error and get the first ten items in my column which display the "Investigation complete' phrase?
Thank you!
Aucun commentaire:
Enregistrer un commentaire