Reputation: 3
I'm trying to get rid of the rows in which indeXLE$XLE == 0 by running this code:
for (i in 1:6975) {
if (indeXLE$XLE[i] == 0) indeXLE <- indeXLE %>% slice(-i)
}
But I'm getting the "missing value where TRUE/FALSE needed" error. Any thoughts?
Upvotes: 0
Views: 44
Reputation: 324
Try using the filter function from the dplyr package.
#install.packages("dplyr")
library(dplyr)
indeXLE <- filter(indeXLE, !is.na(XLE) & XLE != 0)
Upvotes: 1