meta_rename: Replaces names by reference to a metadata dataframe

View source: R/meta_rename.R

meta_renameR Documentation

Replaces names by reference to a metadata dataframe

Description

'meta_rename' allows fast replacement of variable names by key-value pairing with a metadata file.

Usage

meta_rename(df, metadata, old, new)

Arguments

df

A data.frame object for renaming.

metadata

A data.frame object containing the key-value pair

old

An unquoted string of the key column name in the metadata object

new

An unquoted string of the value column name in the metadata object

Value

'data.frame' object with new names as per key-value pairs.

Examples


testdata <-  tibble(a = 0L,
b = 0L,
c = 0L)

meta <-  tibble(DatasetPositon = 1:3,
                VariableID =	letters[1:3],
                VariableType = "integer",
                VariableLabel = c("item1", "item2", "item3"),
                ItemText = c("This is item 1",
                             "This is item 2",
                             "This is item 3")
)

meta_rename(testdata, metadata = meta, old = VariableID, new = VariableLabel)


Lingtax/Qualtrics documentation built on July 4, 2022, 3:24 a.m.