to_snake: to_snake

View source: R/camel_snake.R

to_snakeR Documentation

to_snake

Description

Converts a vector of strings (e.g., column names) from camelCase to snake_case.

Usage

to_snake(x, nums_to_snake = T)

Arguments

x

An atomic vector (character or coercible to character).

nums_to_snake

Should numbers be snaked as well? ('z1' –> 'z_1')

Details

to_snake() will return the input as a character vector with a warning unless there is at least one capital letter not in the first position somewhere in the set of input strings.

E.g., to_snake(c('aaa', 'bbb', 'Ccc')) will return x and a warning.

No dependencies.

Value

A vector.

Examples

camels <- c('dromedaryCamel', 'wildBactrianCamel', 'BactrianLookingUp',
'aCaravanOf10Camels', 'aLargerCaravanOf11')
to_snake(camels)


jacob-gg/manager documentation built on July 2, 2024, 2:09 a.m.