Format character strings to use kebab-style formatting, where word boundaries are defined by dashes/hyphens (e.g. this-is-kebab-case).

kebabCase(object, ...)

# S4 method for character
kebabCase(
  object,
  rename = FALSE,
  recursive = FALSE,
  smart = TRUE,
  prefix = !rename
)

Arguments

object

Object.

rename

logical(1). File rename mode. Requires that input contains files and/or directories that exist on disk. Both case-sensitive (e.g. Linux) and -insensitive (e.g. macOS, Winddows) file systems are supported.

The prefix and smart arguments are supported in this mode.

recursive

logical(1). Should the function recurse into directories? Only applicable when rename = TRUE.

smart

logical(1). Handle complicated special cases, such as mixed case acronyms, plus/minus, percentages, etc.

prefix

logical(1). Prepend "X" character if necessary, when string begins with a syntactically invalid character, such as a number or non-alphanumeric. Note that names are always made syntactically valid when applicable with "X" prefix. See make.names() for details.

Enabled by default for string mode, but disabled by default for rename mode, when applicable.

...

Additional arguments.

Value

Modified object.

Details

Kebab case is recommended for URL slugs and file names. However, they should not be used for names in R, since dashes are not valid, and should be substituted with underscores or periods instead.

Note

Updated 2020-01-27.

Examples

data(syntactic, package = "AcidTest") object <- syntactic$character kebabCase(object)
#> [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"