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

# S4 method for ANY
snake(object)

# S4 method for character
snake(object)

# S4 method for factor
snake(object)

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

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

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

# S4 method for DataFrame
snake(object, rownames = FALSE, colnames = TRUE)

# S4 method for GRanges
snake(object)

# S4 method for GRangesList
snake(object)

# S4 method for SummarizedExperiment
snake(object, rownames = FALSE,
  colnames = TRUE)

Arguments

object

Object.

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.

Value

Modified object. Contains syntatically valid names. For objects supporting names(), the underlying data returns unchanged, except for character or vector class.

Details

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

Examples

data(mn, package = "acidtest") lapply(mn, snake)
#> $character #> [1] "hello_world" "hello_world" "rnai_clones" #> [4] "n_count" "tx2gene" "tx2_gene_id" #> [7] "g2m_score" "worfdb_html_remap" "mazda_rx4" #> [10] "percent_gc" "x5prime" "x5_3_bias" #> [13] "x123" NA #> #> $namedCharacter #> 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 #> #> $dataFrame #> 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 #> #> $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 #> #> $tibble #> # A tibble: 6 x 11 #> manufacturer model displ year cyl trans drv cty hwy fl class #> <chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr> #> 1 audi a4 1.8 1999 4 auto(l5) f 18 29 p compa… #> 2 audi a4 1.8 1999 4 manual(m5) f 21 29 p compa… #> 3 audi a4 2 2008 4 manual(m6) f 20 31 p compa… #> 4 audi a4 2 2008 4 auto(av) f 21 30 p compa… #> 5 audi a4 2.8 1999 6 auto(l5) f 16 26 p compa… #> 6 audi a4 2.8 1999 6 manual(m5) f 18 26 p compa… #> #> $list #> $list$item_a #> [1] 1 2 #> #> $list$item_b #> [1] 3 4 #> #>