R/grep_df_names.R

#' Search a data frames variable names for a pattern
#'
#' @description Takes a data frame and search for a regular expression in the variables names.
#'
#' @details
#'
#'
#'
#'
#' @param df Data frame.
#' @param pattern Regular expression for which variable names are to be searched.
#'
#' @export
table_summary <- function(df      = mtcars,
                          pattern = 'mpg',
                          ...){
    df[,grepl(pattern, names(df))] %>% names()
}
ns-ctru/ctru documentation built on May 23, 2019, 9:34 p.m.