Modify the case of the string.

string_upper(s)
string_lower(s)
string_swapcase(s)
string_titlecase(s)

Arguments

s

A string (character) vector.

Value

Character vector.

Details

The upper() functions make all characters in a string vector in their capitalized case.

The string_lower() function makes the same vector in their lower case.

The string_swapcase() function switches the case for each character in a string vector.

The string_titlecase() function converts the first character of each word to uppercase.

The synonym pattern of these functions are s_*() and *() (replace asterisks with upper, lower, swapcase, or titlecase).

See also

Examples

string_upper(rownames(mtcars))
#> [1] "MAZDA RX4" "MAZDA RX4 WAG" "DATSUN 710" #> [4] "HORNET 4 DRIVE" "HORNET SPORTABOUT" "VALIANT" #> [7] "DUSTER 360" "MERC 240D" "MERC 230" #> [10] "MERC 280" "MERC 280C" "MERC 450SE" #> [13] "MERC 450SL" "MERC 450SLC" "CADILLAC FLEETWOOD" #> [16] "LINCOLN CONTINENTAL" "CHRYSLER IMPERIAL" "FIAT 128" #> [19] "HONDA CIVIC" "TOYOTA COROLLA" "TOYOTA CORONA" #> [22] "DODGE CHALLENGER" "AMC JAVELIN" "CAMARO Z28" #> [25] "PONTIAC FIREBIRD" "FIAT X1-9" "PORSCHE 914-2" #> [28] "LOTUS EUROPA" "FORD PANTERA L" "FERRARI DINO" #> [31] "MASERATI BORA" "VOLVO 142E"
string_lower(rownames(mtcars))
#> [1] "mazda rx4" "mazda rx4 wag" "datsun 710" #> [4] "hornet 4 drive" "hornet sportabout" "valiant" #> [7] "duster 360" "merc 240d" "merc 230" #> [10] "merc 280" "merc 280c" "merc 450se" #> [13] "merc 450sl" "merc 450slc" "cadillac fleetwood" #> [16] "lincoln continental" "chrysler imperial" "fiat 128" #> [19] "honda civic" "toyota corolla" "toyota corona" #> [22] "dodge challenger" "amc javelin" "camaro z28" #> [25] "pontiac firebird" "fiat x1-9" "porsche 914-2" #> [28] "lotus europa" "ford pantera l" "ferrari dino" #> [31] "maserati bora" "volvo 142e"
string_swapcase(rownames(mtcars))
#> [1] "mAZDA rx4" "mAZDA rx4 wAG" "dATSUN 710" #> [4] "hORNET 4 dRIVE" "hORNET sPORTABOUT" "vALIANT" #> [7] "dUSTER 360" "mERC 240d" "mERC 230" #> [10] "mERC 280" "mERC 280c" "mERC 450se" #> [13] "mERC 450sl" "mERC 450slc" "cADILLAC fLEETWOOD" #> [16] "lINCOLN cONTINENTAL" "cHRYSLER iMPERIAL" "fIAT 128" #> [19] "hONDA cIVIC" "tOYOTA cOROLLA" "tOYOTA cORONA" #> [22] "dODGE cHALLENGER" "amc jAVELIN" "cAMARO z28" #> [25] "pONTIAC fIREBIRD" "fIAT x1-9" "pORSCHE 914-2" #> [28] "lOTUS eUROPA" "fORD pANTERA l" "fERRARI dINO" #> [31] "mASERATI bORA" "vOLVO 142e"