This message appeared: "contains implicit NA, consider using `forcats::fct_explicit_na" should i worry?

Hi.
This message appeared: "contains implicit NA, consider using `forcats::fct_explicit_na" should i worry?

The entire operation on the console:

> selected_nzes2011 %>% 
+   group_by(jnzflike, numlikenzf) %>% 
+   summarise(count = n())
# A tibble: 13 x 3
# Groups:   jnzflike [13]
   jnzflike   numlikenzf count
   <fct>           <dbl> <int>
 1 0                   0   622
 2 1                   1   298
 3 10                 10   134
 4 2                   2   266
 5 3                   3   227
 6 4                   4   162
 7 5                   5   544
 8 6                   6   165
 9 7                   7   138
10 8                   8   107
11 9                   9    81
12 Don't know         NA   224
13 NA                 NA   133
Warning messages:
1: Factor `jnzflike` contains implicit NA, consider using `forcats::fct_explicit_na` 
2: Factor `jnzflike` contains implicit NA, consider using `forcats::fct_explicit_na`

It's just warning you that the factor jnzflike contains an NA level. Whether this is a problem or not depends on what you are trying to do.

Some R functions don't report NA values (see example below) which could be misleading. So, a way to guard against this is to turn the NA values into their own level (i.e. make it explicit). You can use forcats::fct_explicit_na() for this as shown below.

table(iris$Species)
#> 
#>     setosa versicolor  virginica 
#>         50         50         50

iris[1, "Species"] <- NA

table(iris$Species)
#> 
#>     setosa versicolor  virginica 
#>         49         50         50

iris$Species <- forcats::fct_explicit_na(iris$Species)

table(iris$Species)
#> 
#>     setosa versicolor  virginica  (Missing) 
#>         49         50         50          1

Created on 2020-06-06 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.