Prefix and postfix can include more than one value that are added in the same
order provided. For str_affix()
, the string must be a single character
string.
Usage
str_affix(
string = NULL,
prefix = NULL,
postfix = NULL,
sep = "_",
pad = NULL,
width = NULL,
use_clean_names = TRUE,
case = "snake",
replace = c(`'` = "", `"` = "", `%` = "_pct_", `#` = "_num_"),
use_make_names = TRUE,
call = caller_env(),
...
)
str_prefix(
string = NULL,
prefix = NULL,
sep = "_",
is_postfix = FALSE,
date.format = "%Y-%m-%d",
time.format = "%Y-%m-%d_%I-%M-%S_%p",
use_clean_names = TRUE,
case = "snake",
replace = c(`'` = "", `"` = "", `%` = "_pct_", `#` = "_num_"),
use_make_names = TRUE,
...
)
Arguments
- string
A single string that the attach prefix or postfix is added to.
- prefix
Character string or character vector to add to string parameter as a prefix.
- postfix
Character string or character vector to add to string parameter as a postfix.
- sep
Separator character passed as the collapse parameter of
paste()
.- pad
Single padding character added to digits in string; defaults to "0"
- width
Minimum width of padded strings.
- use_clean_names
If
TRUE
, prefix, postfix, and string are all converted to snake case withjanitor::make_clean_names()
.- case
The desired target case (default is
"snake"
) will be passed tosnakecase::to_any_case()
with the exception of "old_janitor", which exists only to support legacy code (it preserves the behavior ofclean_names()
prior to addition of the "case" argument (janitor versions <= 0.3.1). "old_janitor" is not intended for new code. Seeto_any_case
for a wide variety of supported cases, including "sentence" and "title" case.- replace
A named character vector where the name is replaced by the value.
- use_make_names
Should
make.names()
be applied to ensure that the output is usable as a name without quoting? (Avoidingmake.names()
ensures that the output is locale-independent but quoting may be required.)- call
The execution environment of a currently running function, e.g.
caller_env()
. The function will be mentioned in error messages as the source of the error. See thecall
argument ofabort()
for more information.- ...
Additional parameters passed to janitor::make_clean_names() if use_clean_names is
TRUE
.- is_postfix
If
TRUE
, use the prefix string as a postfix; defaults toFALSE
.- date.format, time.format
Date or time format. Only used by str_prefix if prefix is "date" or "time" and not currently accessible when using
str_affix()
ormake_filename()
.