View source: R/find_variables.R
find_variables | R Documentation |
Searches for variables in a data frame based on a pattern and provides summary statistics. If a pattern is provided, matches variables using exact matching first, then uses Jaro-Winkler distance for fuzzy matching. Returns summary statistics including variable type, missing value percentage, number of unique values, and numeric summaries (min, max, mean) where applicable.
find_variables(data, pattern = "", n = 10)
data |
A data frame or tibble to search through |
pattern |
Character string. Pattern to match variable names against. Empty pattern returns the first n variables (default: "") |
n |
Integer. Maximum number of variables to return (default: 10) |
The function performs the following: 1. For empty patterns, selects the first n variables 2. For provided patterns: - First finds exact matches (case-insensitive) - If needed, adds fuzzy matches using Jaro-Winkler distance 3. Generates summary statistics with proper formatting: - Missing values shown as percentages - Numeric summaries rounded to 2 decimal places - NA for non-applicable metrics (e.g., mean for character columns)
Invisibly returns a tibble with variable summaries and prints a formatted table to console. The table includes: Variable name, Type, Missing percentage, Unique value count, and numeric summaries (Min, Max, Mean) where applicable.
## Not run:
find_variables(mtcars)
find_variables(mtcars, "cyl", n = 5)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.