Skip to contents

Prepend DF Name to Column Names

Usage

prepend_df_name(
  data,
  df_name = NULL,
  include = c(everything(), -any_of(getOption("affirm.id_cols")))
)

Arguments

data

a data frame

df_name

string indicating the data frame name to prepend to the column names. If not supplied, function will try to identify the data frame name. NOTE: We can only get the correct name if the data frame has been piped directly to this function without any other piped function between.

include

tidyselect expression to identify columns to modify name. Default is all columns, except those identified in options("affirm.id_cols").

Value

a data frame

Examples

DM |>
 prepend_df_name()
#> # A tibble: 4 × 3
#>   DM.SUBJECT DM.AGE DM.RACE                                  
#>        <dbl>  <dbl> <chr>                                    
#> 1          1     40 Asian                                    
#> 2          2     70 Black or African American                
#> 3          3     50 Native American                          
#> 4          4     60 Native Hawaiian or Other Pacific Islander