rename_vector: Rename character vector

View source: R/rename_vector.R

rename_vectorR Documentation

Rename character vector

Description

Translates names between different lexicons (naming schema).

Usage

rename_vector(
  input,
  lexin = c("original", "sequential", "gsed", "gsed2"),
  lexout = c("gsed2", "original", "sequential", "gsed"),
  notfound = "copy",
  contains = c("", "Ma_SF_", "Ma_LF_", "bsid_"),
  underscore = TRUE,
  trim = "Ma_",
  lowercase = TRUE
)

Arguments

input

A character vector with names to be translated

lexin

A string indicating the input lexicon. One of "original", "sequential", "gsed" or "gsed2". Default is "original".

lexout

A string indicating the output lexicon. One of "original", "sequential", "gsed" or "gsed2". Default is "gsed2".

notfound

A string indicating what to do some input value is not found

contains

A string to filter the translation table prior to matching. Needed to prevent double matches. The default ("") does not filter.

underscore

Replaces space (" ") and dash ("-") by underscore ("_")

trim

A substring to be removed from 'input'. Defaults to "Ma_".

lowercase

Sets all variables in lower case. in 'lexin'? The default 'notfound = "copy"' copies the input values into the output value. In other cases (e.g. '""' or 'NA_character_'), the function uses the string specified in 'notfound' as a replacement value.

Value

A character vector of the same length as 'input' with processed names.

Examples

input <- c("file", "GSED_ID", "Ma_SF_Parent ID", "Ma_SF_C01", "Ma_SF_C02")
rename_vector(input)
rename_vector(input, lexout = "sequential", lowercase = FALSE)
rename_vector(input, lexout = "gsed", trim = "Ma_SF_")

D-score/gsedread documentation built on April 19, 2023, 8:59 a.m.