find_columns_by_pattern {Tivy} | R Documentation |
Find columns by pattern
Description
Identifies columns in a data frame that match a specific pattern. Useful for finding length columns, weight columns, etc.
Usage
find_columns_by_pattern(data, pattern = "weighted_", sort = TRUE)
Arguments
data |
Data frame to search. |
pattern |
Regular expression pattern to match. |
sort |
Logical. Sort results numerically. |
Value
Character vector of matching column names.
Examples
# Create dummy data
data <- data.frame(
weighted_8.5 = c(1, 2, 3),
weighted_10 = c(4, 5, 6),
`8` = c(7, 8, 9),
other = c(10, 11, 12)
)
# Find weighted columns
weighted_cols <- find_columns_by_pattern(data, pattern = "weighted_")
# Find numeric-only named columns (e.g., "8")
length_cols <- find_columns_by_pattern(data, pattern = "")
[Package Tivy version 0.1.1 Index]