string_concat: Concatenate strings together

View source: R/string_concat.R

string_concatR Documentation

Concatenate strings together

Description

Concatenate strings together.

Usage


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, ...)

Arguments

a

A string (character) vector.

b

A string (character) vector.

...

Parameters passed to paste0() or string_flag().

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.

Details

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)).

Value

Character vector.

See Also

https://github.com/robertschnitman/stringops

Examples

"a" %&% "b"
string_prefix(rownames(mtcars), "A")
string_suffix(rownames(mtcars), "Z")
string_flag('123456789', '0', 10)


robertschnitman/stringops documentation built on Aug. 15, 2022, 3:46 p.m.