I'm trying to count the number of time each row in my dataframe have both "Passed" in the result column and "Yes" in position. However, I'm getting an error in a loop I'm running.
Error in if (current$position == "Yes" & current$result == "Passed") { :
argument is of length zero
I heard that this can happen when you compare to null
or NA
values but the values in the table are never null
or NA
.
This is the code I have for my loop.
count_votes <- 0
recent <- slice(flatten_votes, 1:20)
for (i in 1:length(recent)) {
current <- slice(recent, i)
if (current$position == "Yes" & current$result == "Passed") {
count_votes = count_votes + 1
}
}