Concatenate strings together.
<!-- %&% -->
string_concat(a, b, ...)
string_prefix(s, prefix)
string_suffix(s, suffix)
string_flag(s, flag, width, which = c('left', 'right', 'both'))
string_flagv(s, ...)
| a | A string (character) vector. |
|---|---|
| b | A string (character) vector. |
| ... | Parameters passed to |
| s | A string (character) vector. |
| collapse | A string by which to separate the elements of a vector. |
| flag | Character or number to append to a string. |
| width | Number of characters a string should be. |
| which | Side to flag a string. |
Character vector.
The %&% operator acts similar to BASIC's &, concatenating two elements together. For more general usage, use string_concat(), whose optional inputs get passed to paste0().
string_prefix() and its synonyms prefix a string to a vector, while string_suffix() and its synonyms suffix a string to a vector.
string_flag() is a scalar function that appends a character or number to a string if it does not meet a specified width.
string_flagv() is a vectorized version of string_flag().
The synonym pattern of these functions are s_*() and *() (replace asterisks with prefix, suffix, and flag(v)).
"a" %&% "b"#> [1] "ab"#> [1] "AMazda RX4" "AMazda RX4 Wag" "ADatsun 710" #> [4] "AHornet 4 Drive" "AHornet Sportabout" "AValiant" #> [7] "ADuster 360" "AMerc 240D" "AMerc 230" #> [10] "AMerc 280" "AMerc 280C" "AMerc 450SE" #> [13] "AMerc 450SL" "AMerc 450SLC" "ACadillac Fleetwood" #> [16] "ALincoln Continental" "AChrysler Imperial" "AFiat 128" #> [19] "AHonda Civic" "AToyota Corolla" "AToyota Corona" #> [22] "ADodge Challenger" "AAMC Javelin" "ACamaro Z28" #> [25] "APontiac Firebird" "AFiat X1-9" "APorsche 914-2" #> [28] "ALotus Europa" "AFord Pantera L" "AFerrari Dino" #> [31] "AMaserati Bora" "AVolvo 142E"#> [1] "Mazda RX4Z" "Mazda RX4 WagZ" "Datsun 710Z" #> [4] "Hornet 4 DriveZ" "Hornet SportaboutZ" "ValiantZ" #> [7] "Duster 360Z" "Merc 240DZ" "Merc 230Z" #> [10] "Merc 280Z" "Merc 280CZ" "Merc 450SEZ" #> [13] "Merc 450SLZ" "Merc 450SLCZ" "Cadillac FleetwoodZ" #> [16] "Lincoln ContinentalZ" "Chrysler ImperialZ" "Fiat 128Z" #> [19] "Honda CivicZ" "Toyota CorollaZ" "Toyota CoronaZ" #> [22] "Dodge ChallengerZ" "AMC JavelinZ" "Camaro Z28Z" #> [25] "Pontiac FirebirdZ" "Fiat X1-9Z" "Porsche 914-2Z" #> [28] "Lotus EuropaZ" "Ford Pantera LZ" "Ferrari DinoZ" #> [31] "Maserati BoraZ" "Volvo 142EZ"string_flag('123456789', '0', 10)#> [1] "0123456789"