field_case: Modify Case & Separators in Field Names

Description Usage Arguments Details Value Author(s) See Also

View source: R/panthr.r

Description

field_case is a versatile function that accepts tabular data with column headers or field names and modifies their case, separators and, for special cases, initial letter capitalization.

Usage

1
field_case(data, case = "lower", sep = "_", lower.case = TRUE)

Arguments

data

A data.frame, matrix, or other tabular object with identifiable column headers or field names.

case

A single character string in quotations specifying the case in which column headers or field names will convert. Acceptable parameters include "lower", "upper", "title", "camel", "snake", "leopard", and "kebab". Defaults to case = "lower".

sep

A single character string in quotations specifying the character(s) used to separate words in column headers or field names. Defaults to a single space, i.e. sep = " ".

Conflicting parameters passed to sep = are overridden with exotic cases, since they use specific separators by default (e.g. "-", "_", ".") or no separator in the case of "camel". In such cases, a warning is thrown alerting the user of the override.

lower.case

A logical value (TRUE or FALSE) indicating whether all characters in one or more column headers or field names should be lowercase. Defaults to lower.case = TRUE.

Conflicting parameters passed to lower.case = may be overridden when conflicting with parameters passed to argument case =, e.g. "title", "upper", and "camel". This argument distinguishes "upper" and "lower" cases, particularly for exotic cases, e.g. "upper snake case" and "lower snake case".

Details

field_case automatically formats field names to all lowercase letters and underscore separators (_). However, it supports both "lower", "upper", and "title" cases, exotic cases such as "camel", "kebab", "snake", and "leopard", and custom separators where applicable.

Objects passed to argument data = that are not tabular or, if comprised of a single column, without column names will throw an error.

Value

A data.frame object or other tabular data structure with a modified case and separators in column headers and field names specified by the user.

Author(s)

Jamison R. Crawford, Institutional Research Associate, Georgia State University

See Also

gsub, names, colnames, ncol, tolower, toupper, toTitleCase


jamisoncrawford/panthr documentation built on March 9, 2020, 6:18 p.m.