Learn R Programming

epikit (version 0.1.6)

rename_redundant: Cosmetically relabel all columns that contains a certain pattern

Description

These function are only to be used cosmetically before kable and will likely return a data frame with duplicate names.

Usage

rename_redundant(x, ...)

augment_redundant(x, ...)

Value

a data frame.

Arguments

x

a data frame

...

a series of keys and values to replace columns that match specific patterns.

Author

Zhian N. Kamvar

Details

  • rename_redundant fully replaces any column names matching the keys

  • augment_redundant will take a regular expression and rename columns via gsub().

Examples

Run this code

df <- data.frame(
  x = letters[1:10],
  `a n` = 1:10,
  `a prop` = (1:10) / 10,
  `a deff` = round(pi, 2),
  `b n` = 10:1,
  `b prop` = (10:1) / 10,
  `b deff` = round(pi * 2, 2),
  check.names = FALSE
)
df
print(df <- rename_redundant(df, "%" = "prop", "Design Effect" = "deff"))
print(df <- augment_redundant(df, " (n)" = " n$"))

Run the code above in your browser using DataLab