View source: R/rename_excel2R.R
rename_excel2R | R Documentation |
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
rename_excel2R(dat)
dat |
Dataset to rename |
dataframe or tibble containing the updated names
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.