rename_prefix {campfin} R Documentation

## Convert data frame name suffixes to prefixes

### Description

When performing a dplyr::left_join(), the suffix argument allows the user to replace the default .x and .y that are appended to column names shared between the two data frames. This function allows a user to convert those suffixes to prefixes.

### Usage

rename_prefix(df, suffix = c(".x", ".y"), punct = TRUE)


### Arguments

 df A joined data frame. suffix If there are non-joined duplicate variables in x and y, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2. Will be converted to prefixes. punct logical; Should punctuation at the start of the suffix be detected and placed at the end of the new prefix? TRUE by default.

### Value

A data frame with new column names.

### Examples

a <- data.frame(x = letters[1:3], y = 1:3)
b <- data.frame(x = letters[1:3], y = 4:6)
df <- dplyr::left_join(a, b, by = "x", suffix = c(".a", ".b"))
rename_prefix(df, suffix = c(".a", ".b"), punct = TRUE)


[Package campfin version 1.0.9 Index]