Format character strings to use snake-style formatting, where word boundaries are defined by underscores (e.g. this_is_snake_case).

snakeCase(object, ...)

# S4 method for atomic
snakeCase(object, names = TRUE)

# S4 method for character
snakeCase(object, names = TRUE)

# S4 method for factor
snakeCase(object, names = TRUE)

# S4 method for list
snakeCase(object, names = TRUE)

# S4 method for matrix
snakeCase(object, rownames = FALSE, colnames = TRUE)

# S4 method for data.frame
snakeCase(object, rownames = FALSE,
  colnames = TRUE)

# S4 method for Vector
snakeCase(object, names = TRUE, mcols = TRUE,
  metadata = TRUE)

# S4 method for DataTable
snakeCase(object, rownames = FALSE,
  colnames = TRUE, mcols = TRUE, metadata = TRUE)

# S4 method for Ranges
snakeCase(object, names = FALSE, mcols = TRUE,
  metadata = TRUE)

# S4 method for Matrix
snakeCase(object, rownames = FALSE, colnames = TRUE)

# S4 method for SummarizedExperiment
snakeCase(object, rownames = FALSE,
  colnames = TRUE, assayNames = TRUE, rowData = TRUE,
  colData = TRUE, metadata = TRUE)

snake(...)

Arguments

object

Object.

names

logical(1). Sanitize names.

rownames

logical(1). Apply sanitization on row names. This is not generally recommended by default, since rownames commonly contain gene identifiers that should not be modified.

colnames

logical(1). Apply sanitization on column names. This is generally recommended by default.

mcols

logical(1). Sanitize names of metadata columns (i.e. DataFrame).

metadata

logical(1). Sanitize metadata names.

assayNames

logical(1). Sanitize assay names.

rowData

logical(1). Sanitize the row data names.

colData

logical(1). Sanitize column names of column data.

...

Additional arguments.

Value

Modified object, with names formatted in snake case.

Details

Snake case is recommended by the tidyverse for variable and function names.

Examples

data(syntactic, package = "acidtest") lapply(syntactic, snakeCase)
#> $character #> [1] "percent_gc" "x10um" "x5_3_bias" #> [4] "x5prime" "g2m_score" "hello_world" #> [7] "hello_world" "mazda_rx4" "n_count" #> [10] "rnai_clones" "tx2gene" "tx2_gene_id" #> [13] "worfdb_html_remap" "x123" NA #> #> $character_named #> item_a item_b #> "hello_world" "hello_world" #> #> $factor #> sample_1 sample_2 sample_3 sample_4 #> group_1 group_1 group_2 group_2 #> Levels: group_1 group_2 #> #> $list #> $list$item_a #> [1] 1 2 #> #> $list$item_b #> [1] 3 4 #> #> #> $matrix #> murder assault urban_pop rape #> Alabama 13.2 236 58 21.2 #> Alaska 10.0 263 48 44.5 #> Arizona 8.1 294 80 31.0 #> Arkansas 8.8 190 50 19.5 #> California 9.0 276 91 40.6 #> Colorado 7.9 204 78 38.7 #> #> $data.frame #> murder assault urban_pop rape #> Alabama 13.2 236 58 21.2 #> Alaska 10.0 263 48 44.5 #> Arizona 8.1 294 80 31.0 #> Arkansas 8.8 190 50 19.5 #> California 9.0 276 91 40.6 #> Colorado 7.9 204 78 38.7 #>