Last active
May 6, 2020 16:36
-
-
Save joelgombin/c3404877787181b96ffa383165a5216a to your computer and use it in GitHub Desktop.
Compter tous les nulls et autres d'un JDD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
base <- read_csv("./Documents/Base_menage-extrait.csv") | |
is_null_vector <- function(x) purrr::map_lgl(x, ~ is.null(.)) | |
base %>% | |
summarise(across(.fns = list(NAs = ~ sum(is.na(.)), | |
NULLs = ~ sum(is_null_vector(.) | . %in% "NULL"), | |
empties = ~ sum(. %in% "")))) %>% | |
pivot_longer(everything()) %>% | |
separate(name, c("name", "type"), "_(?=NAs|NULLs|empties)") %>% | |
pivot_wider(names_from = type, values_from = value) |
Author
joelgombin
commented
May 2, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment