df.name.change: This function changes multiple colnames of a df there is a...

Description Usage Arguments Examples

Description

This function changes multiple colnames of a df there is a range match option

Usage

1
2
df.name.change(df, original_names, new_names, range_match = F, fixed = F,
  invert = F)

Arguments

df

a data.frame

original_names

a colname/ an array of colnames you want to change

new_names

a target colname/ an array of target colnames, must match the number of names in original_names

range_match

just like in Excel match(,,1), default is False

fixed:

only applicable if range_match = T, used in grep, please see grep for purpose

invert:

only applicable if range_match = T, used in grep, please see grep for purpose, essentially making original_names columns you do not want to change name

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
range_match True test data set
df <- flat_data
original_names <- c("households", "Installed")
new_names <- c("TV.households","Installed.base")
range_match = T
range_match False test data set
df <- mtcars
original_names <- c("mpg","disp","wt")
new_names <- c("test1","test2","test3")
range_match = F

marcuskhl/BasicSettings documentation built on May 21, 2019, 11:44 a.m.