rename_excel2R: Pipeable column header rename function

View source: R/rename_excel2R.R

rename_excel2RR Documentation

Pipeable column header rename function

Description

This function takes a data frame or tibble object and replaces any 'bad' column names (containing whitespace, dashes, slashes, etc) and replaces them with more R friendly column names. Most often when imported manual Excel data into R for further analysis

Usage

rename_excel2R(dat)

Arguments

dat

Dataset to rename

Value

dataframe or tibble containing the updated names

Examples

library(tibble)
library(stringr)
set.seed(1234)

dat = tibble(
"Column 1" = 1:10,
"Column#2" = sample(1:10, size = 10, replace = T),
"Col1/Col2" = `Column 1`/`Column#2`,
"| New~Column |" = "test"
)

newdat = rename_excel2R(dat)
newdat
newdat2 = dat %>% rename_excel2R
all.equal(newdat, newdat2)

pipe_test = dat %>%
  rename_excel2R %>%
  select_if(is.double)


Ajfrick/ajfhelpR documentation built on June 30, 2023, 12:56 a.m.