# StrCap: Capitalize the First Letter of a String In DescTools: Tools for Descriptive Statistics

## Description

Capitalize the first letter of each element of the string vector.

## Usage

 `1` ```StrCap(x, method=c("first", "word", "title")) ```

## Arguments

 `x` string to be capitalized. `method` one out of `"first"` (default), `"word"`, `"title"`. `"first"` will only capitalize the first character of a string. `"word"` will capitalize all found words and `"title"` will also capitalize wordwise, but leave out: a, an, the, at, by, for, in, of, on, to, up, and, as, but, s, or and nor.)

## Value

Returns a vector of charaters with the first letter capitalized

## Author(s)

Charles Dupont <charles.dupont@vanderbilt.edu>, Andri Signorell <andri@signorell.net> (methods word and title)

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17``` ```# capitalize first character StrCap(c("Hello", "bob", "daN")) # but not all... StrCap(c("Hello bob, how are you?", "And you, DANIEL?")) # wordwise StrCap(c("Capitalize all words in titles of publications and documents", "but Up and UP, not all and all", NA), method="word") # wordwise omitting the ones listed above StrCap(c("Capitalize all words in titles of publications and documents", "but Up and UP, not all and all", NA), method="title") # do not touch non alphabetic characters z <- c("Lorem ipsum dolor", "-- sit amet", "consectetur --", " adipiscing elit ", "sed,.--(do) / +-*eiusmod") StrCap(z, method="title") ```

### Example output

```[1] "Hello" "Bob"   "DaN"
[1] "Hello bob, how are you?" "And you, DANIEL?"
[1] "Capitalize All Words In Titles Of Publications And Documents"
[2] "But Up And UP Not All And All"
[3] NA
[1] "Capitalize All Words in Titles of Publications and Documents"
[2] "but up and up, Not All and All"
[3] NA
[1] "Lorem Ipsum Dolor"        "-- Sit Amet"
[3] "Consectetur --"           " Adipiscing Elit "
[5] "Sed,.--(Do) / +-*Eiusmod"
```

DescTools documentation built on June 17, 2021, 5:12 p.m.