R/get_unique_col_names.R

Defines functions get_unique_col_names

get_unique_col_names <- function(df){
  nrow(df) -> rws
  V1 <- column <- NULL

  df %>%
    dplyr::summarize(dplyr::across(.fns = ~dplyr::n_distinct(.) == rws)) %>%
    presenter::pivot_summary() %>%
    dplyr::filter(V1) %>%
    dplyr::pull(column)
}


get_min_unique_col_names <- function(df){
  nrow(df) -> rws
  V1 <- column <- NULL

  df %>%
    dplyr::summarize(dplyr::across(.fns = ~dplyr::n_distinct(.) == rws)) %>%
    presenter::pivot_summary() %>%
    dplyr::filter(V1) %>%
    dplyr::pull(column)
}

get_min_unique_col_names <- function(df){
  nrow(df) -> rws
  V1 <- column <- NULL

  df %>%
    dplyr::summarize(dplyr::across(.fns = ~dplyr::n_distinct(.))) %>%
    presenter::pivot_summary() %>%
    dplyr::filter(V1 == min(V1)) %>%
    dplyr::pull(column)
}

Try the autostats package in your browser

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

autostats documentation built on Nov. 10, 2022, 6:13 p.m.