lettercases: Additional lettercase conversions

Description Usage Arguments tocamel tocapital See Also Examples

Description

Family of functions to change the lettercase of strings to camel or capital case.

Usage

1
2
3
tocamel(x, collapseall = FALSE)

tocapital(x, fix_mc = FALSE, collapseall = FALSE)

Arguments

x

A character vector, or list object of character vectors.

collapseall

A logical scalar. Indicate whether or not you want a single character vector as your output. Default is FALSE.

fix_mc

A logical scalar. Indicate if Mc* names (like McDowell) should be double capitalized. Default is FALSE.

tocamel

Convert character vectors to camelcase (ie PaulJames)

Takes a character vector, or list object of character vectors and converts the case to camelcase. Outputs the same object and number of elements as the input unless the collapseall flag is set to TRUE, in which case it will output a single character vector.

tocapital

Convert character vectors to capitalcase (ie Paul James)

Takes a character vector, or list object of character vectors and converts the case to capitalcase (AKA, title case). Outputs the same object and number of elements as the input unless the collapseall flag is set to TRUE, in which case it will output a single character vector.

See Also

toupper tolower

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
tocamel("jonny appleseed")
tocamel(c("jonny appleseed", "GraNDpa CrIPEs-mcgee"))

# using a list object
tocamel(
  list(
    c("THE", "DARK", "KNIGHT")
  , c("rises", "from the", "lazerus PIT")
  )
)

# using a list object and collapseall
tocamel(
  list(
    c("THE", "DARK", "KNIGHT")
  , c("rises", "from the", "lazerus PIT")
  )
  , collapseall = TRUE
)


tocapital("jonny appleseed")

# using a list object
tocapital(
  list(
    c("THE", "DARK", "KNIGHT")
  , c("rises", "from the", "lazerus PIT")
  )
)

# using a list object and collapseall
tocapital(
  list(
    c("THE", "DARK", "KNIGHT")
  , c("rises", "from the", "lazerus PIT")
  )
  , collapseall = TRUE
)

# examples of not fixing Mc* names (the default) vs fixing them
tocapital(c("jonny appleseed", "GraNDpa CrIPEs-mcgee"))
tocapital(
    c("jonny appleseed", "GraNDpa CrIPEs-mcgee")
  , fix_mc = TRUE
)

Paul-James/pjames documentation built on Aug. 9, 2019, 12:18 p.m.