stand_str: Standardize character vectors to a common format

View source: R/stand_str.R

stand_strR Documentation

Standardize character vectors to a common format

Description

Standardize character vectors to a common format

Usage

stand_str(str_in, sep = "-", case = "upper")

Arguments

str_in

Character vector

sep

Character defining the word delimiter for the output character vector, either " " (space), ".", "-", "_", or "" (no delimiter)

case

String consisting of either "upper" or "lower" to select whether to convert output to all uppercase or all lowercase

Details

This function somewhat crudely attempts to force character vectors to a common format. It does this by converting everything to upper or lowercase, and replacing all common word delimiters (space, period, underscore, dash, comma) with the selected one. Note that of the three, only underscores or periods will form syntactically- valid R variable names (override by reading in tables with check.names = FALSE). However, underscores can cause problems with reading VCFs in PLINK, as they will by default be interpreted as delimiters for family and individual IDs. Choosing spaces or commas as the output delimiter is generally not recommended, as this can cause issues in whitespace-delimited or comma-delimited text files, respectively.

Value

character vector of same dimensions as input vector, but with all elements updated to the new format


etnite/bwardr documentation built on Jan. 6, 2023, 7:12 a.m.