addSuffixToColumns: Add Suffix to Column Names

View source: R/column.R

addSuffixToColumnsR Documentation

Add Suffix to Column Names

Description

Add Suffix to Column Names

Usage

addSuffixToColumns(data, suffix, except = NULL)

Arguments

data

data frame

suffix

suffix to be added to each column name except the columns given in except

except

names of columns to which no suffix is to be given

Value

data with renamed columns

Examples

d1 <- data.frame(id = 1, a = 2, b = 3)
d2 <- data.frame(id = 1, c = 2, d = 3)

# Using merge the origin of the column gets lost
merge(d1, d2)

# Add a suffix before merging
merge(
  addSuffixToColumns(d1, ".first", except = "id"), 
  addSuffixToColumns(d2, ".second", except = "id"), 
  by = "id"
)


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.