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

vis_miss() column %s NA when % = 0.1 #62

Closed
jenniferthompson opened this issue Dec 29, 2017 · 1 comment · Fixed by #70
Closed

vis_miss() column %s NA when % = 0.1 #62

jenniferthompson opened this issue Dec 29, 2017 · 1 comment · Fixed by #70

Comments

@jenniferthompson
Copy link

I have a column with 0.1% missing, and the column percentage is NA instead of 0.1%. I think the issue is that the case_when() call in label_col_missing_pct doesn't account for the case when x == 0.1; guessing it should be fixed by changing line 80 to >= instead of >. My attempts at a reprex were failing, but happy to try again or submit a PR if either would help!

visdat/R/internals.R

Lines 78 to 82 in de3186b

dplyr::case_when(
x == 0 ~ "0%",
x > 0.1 ~ paste0(x,"%"),
x < 0.1 ~ "<0.1%"
)

@njtierney
Copy link
Collaborator

@jenniferthompson !

Sorry I have overlooked this. This is indeed the case, thank you so much for linking to this line of code, this has made this much easier to debug!

OK, so here is pre the change:

library(visdat)
library(tibble)

temp <- rnorm(n = 10000,
              mean = 25,
              sd = 2.5)

temp[1:10] <- NA

wind <- rnorm(n = 10000,
              mean = 15,
              sd = 7.5)

wind[1:12] <- NA

ozone <- rnorm(n = 10000,
               mean = 43,
               sd = 30)

ozone[1:8] <- NA

dat <- tibble(temp,
              wind,
              ozone)

dat
#> # A tibble: 10,000 x 3
#>     temp  wind ozone
#>    <dbl> <dbl> <dbl>
#>  1    NA    NA NA   
#>  2    NA    NA NA   
#>  3    NA    NA NA   
#>  4    NA    NA NA   
#>  5    NA    NA NA   
#>  6    NA    NA NA   
#>  7    NA    NA NA   
#>  8    NA    NA NA   
#>  9    NA    NA 16.3 
#> 10    NA    NA  4.26
#> # ... with 9,990 more rows

vis_miss(dat)

Created on 2018-03-20 by the reprex package (v0.2.0).

This once I made a change to lines 76 and 80

library(visdat)
library(tibble)

temp <- rnorm(n = 10000,
              mean = 25,
              sd = 2.5)

temp[1:10] <- NA

wind <- rnorm(n = 10000,
              mean = 15,
              sd = 7.5)

wind[1:12] <- NA

ozone <- rnorm(n = 10000,
               mean = 43,
               sd = 30)

ozone[1:8] <- NA

dat <- tibble(temp,
              wind,
              ozone)

dat
#> # A tibble: 10,000 x 3
#>     temp  wind ozone
#>    <dbl> <dbl> <dbl>
#>  1    NA    NA  NA  
#>  2    NA    NA  NA  
#>  3    NA    NA  NA  
#>  4    NA    NA  NA  
#>  5    NA    NA  NA  
#>  6    NA    NA  NA  
#>  7    NA    NA  NA  
#>  8    NA    NA  NA  
#>  9    NA    NA  47.1
#> 10    NA    NA  17.3
#> # ... with 9,990 more rows

vis_miss(dat)

Created on 2018-03-20 by the reprex package (v0.2.0).

I think that is it - but please feel free to open this if it doesn't work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants