R/clean_table.R

Defines functions clean_table

Documented in clean_table

#' Remove columns filled only with NA (missing value)
#'
#' @param df the dataframe to be cleaned
#' @return a dataframe without columns containing only NA
#' @examples
#' \donttest{
#'library(tidyverse)
#'
#'idbank_empl =
#'  get_idbank_list("EMPLOI-SALARIE-TRIM-NATIONAL") %>% #employment
#'  mutate(title = get_insee_title(idbank)) %>%
#'  separate(title, sep = " - ", into = paste0("title", 1:5), fill = "right") %>%
#'  clean_table()
#' }
#' @export
clean_table = function(df){
  df[, colSums(is.na(df)) != nrow(df)]
}

Try the insee package in your browser

Any scripts or data that you put into this service are public.

insee documentation built on Sept. 18, 2022, 1:08 a.m.