Check if Dataset Has Minimum Required Columns
has_min_cols.RdHelper function to determine if a specific dataset has sufficient columns of a given type for analysis.
Helper function to determine if a specific dataset has sufficient columns of a given type for analysis.
Usage
has_min_cols(col_list, dataset_idx, min_count = 1)
has_min_cols(col_list, dataset_idx, min_count = 1)Arguments
- col_list
A named list of column vectors (output from
check_col_types())- dataset_idx
Integer index of the dataset to check
- min_count
Minimum number of columns required (default: 1)
Value
Logical indicating whether the dataset has sufficient columns
Logical indicating whether the dataset has sufficient columns
Examples
ttd <- load_tt_data("Moore's Law")
#> Error in load_tt_data("Moore's Law"): No entries found for title: 'Moore's Law'
num_cols <- check_col_types(ttd, "num")
#> Error: object 'ttd' not found
has_min_cols(num_cols, 1, min_count = 2)
#> Error: object 'num_cols' not found
ttd <- load_tt_data("Moore’s Law")
#> INFO [2026-04-10 16:29:33] Starting import for cpu.csv from https://raw.githubusercontent.com/rfordatascience/tidytuesday/refs/heads/main/data/2019/2019-09-03/cpu.csv
#> SUCCESS [2026-04-10 16:29:33] Successfully loaded cpu.csv
#> INFO [2026-04-10 16:29:33] Starting import for gpu.csv from https://raw.githubusercontent.com/rfordatascience/tidytuesday/refs/heads/main/data/2019/2019-09-03/gpu.csv
#> SUCCESS [2026-04-10 16:29:33] Successfully loaded gpu.csv
#> INFO [2026-04-10 16:29:33] Starting import for ram.csv from https://raw.githubusercontent.com/rfordatascience/tidytuesday/refs/heads/main/data/2019/2019-09-03/ram.csv
#> SUCCESS [2026-04-10 16:29:33] Successfully loaded ram.csv
num_cols <- check_col_types(ttd, "num")
has_min_cols(num_cols, 1, min_count = 2)
#> [1] TRUE