We have code that recently started to give the following warnings whenever we subset a grouped dataframe that results in zero rows. I understand what 'Factor
x contains implicit NA' refers to, and understand that I could use fct_explicit_na to fix the warning; however, this doesnt seem correct to report it in the situation of zero rows (as opposed to actually having NAs). I only see this with grouped dataframes. See this example:
library(dplyr) #Create DF: test <- data.frame(x = factor(c('A', 'B'))) #Group by make grouped_df: test <- test %>% group_by(x) #Subset, resulting in zero rows: ss <- test[test$x == 'C',] # Warning message: # Factor `x` contains implicit NA, consider using `forcats::fct_explicit_na`
I am using dplyr_0.8.3. Thanks for any comments.