Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings given for gg_miss_fct #241

Closed
njtierney opened this issue Oct 21, 2019 · 2 comments
Closed

Warnings given for gg_miss_fct #241

njtierney opened this issue Oct 21, 2019 · 2 comments

Comments

@njtierney
Copy link
Owner

@njtierney njtierney commented Oct 21, 2019

Resolve these warnings:

library(naniar)
gg_miss_fct(riskfactors, marital)
#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`

#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`

#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`

#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`
#> Warning: `cols` is now required.
#> Please use `cols = c(data)`
#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`

#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`

Created on 2019-10-21 by the reprex package (v0.3.0)

@njtierney
Copy link
Owner Author

@njtierney njtierney commented Oct 21, 2019

It's not to do with the plot actually - here's a more minimal reprex:

library(naniar)
risk_group <- dplyr::group_by(riskfactors, marital)
#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`
miss_var_summary(risk_group)
#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`

#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`

#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`
#> Warning: `cols` is now required.
#> Please use `cols = c(data)`
#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`

#> Warning: Factor `marital` contains implicit NA, consider using
#> `forcats::fct_explicit_na`
#> # A tibble: 231 x 4
#> # Groups:   marital [7]
#>    marital variable      n_miss pct_miss
#>    <fct>   <chr>          <int>    <dbl>
#>  1 Married smoke_stop       120    91.6 
#>  2 Married pregnant         117    89.3 
#>  3 Married smoke_last        84    64.1 
#>  4 Married smoke_days        73    55.7 
#>  5 Married drink_average     68    51.9 
#>  6 Married health_poor       67    51.1 
#>  7 Married drink_days        67    51.1 
#>  8 Married weight_lbs         6     4.58
#>  9 Married bmi                6     4.58
#> 10 Married diet_fruit         4     3.05
#> # … with 221 more rows

Created on 2019-10-21 by the reprex package (v0.3.0)

@njtierney
Copy link
Owner Author

@njtierney njtierney commented Oct 21, 2019

I'm not sure if this actually an issue with naniar, it's more an issue with using factors that don't have missingness encoded correctly:

library(naniar)
riskfactors %>% 
  dplyr::mutate(m2 = forcats::fct_explicit_na(marital)) %>% 
  dplyr::group_by(m2)
#> # A tibble: 245 x 35
#> # Groups:   m2 [7]
#>    state sex     age weight_lbs height_inch   bmi marital pregnant children
#>    <fct> <fct> <int>      <int>       <int> <dbl> <fct>   <fct>       <int>
#>  1 26    Fema…    49        190          64  32.7 Married <NA>            0
#>  2 40    Fema…    48        170          68  25.9 Divorc… <NA>            0
#>  3 72    Fema…    55        163          64  28.0 Married <NA>            0
#>  4 42    Male     42        230          74  29.6 Married <NA>            1
#>  5 32    Fema…    66        135          62  24.7 Widowed <NA>            0
#>  6 19    Male     66        165          70  23.7 Married <NA>            0
#>  7 45    Male     37        150          68  22.9 Married <NA>            3
#>  8 56    Fema…    62        170          70  24.4 NeverM… <NA>            0
#>  9 18    Male     38        146          70  21.0 Married <NA>            2
#> 10 8     Fema…    42        260          73  34.4 Separa… No              3
#> # … with 235 more rows, and 26 more variables: education <fct>,
#> #   employment <fct>, income <fct>, veteran <fct>, hispanic <fct>,
#> #   health_general <fct>, health_physical <int>, health_mental <int>,
#> #   health_poor <int>, health_cover <fct>, provide_care <fct>,
#> #   activity_limited <fct>, drink_any <fct>, drink_days <int>,
#> #   drink_average <int>, smoke_100 <fct>, smoke_days <fct>,
#> #   smoke_stop <fct>, smoke_last <fct>, diet_fruit <int>,
#> #   diet_salad <int>, diet_potato <int>, diet_carrot <int>,
#> #   diet_vegetable <int>, diet_juice <int>, m2 <fct>

Created on 2019-10-21 by the reprex package (v0.3.0)

I'm not sure if this should be a problem for naniar, or an issue for the user, who should change their data?

@njtierney njtierney closed this in 630c3d6 Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.