diff --git a/R/report_percent_missing.R b/R/report_percent_missing.R new file mode 100644 index 0000000..b217b15 --- /dev/null +++ b/R/report_percent_missing.R @@ -0,0 +1,17 @@ +report_percent_missing <- function(data, column) { + na_data <- data |> + tably({{column}}) |> + dplyr::filter(is.na({{column}})) + + print(na_data) + + na_column_name <- na_data |> + names() |> + dplyr::nth(1) + + na_data |> + dplyr::pull(percent) |> + percent(multiply_by_100 = FALSE, 2) |> + sprintf(fmt = "\n%s of '%s' are missing.", na_column_name) |> + cat() +}