string: String utility

glueR Documentation

String utility

Description

glue() is a shortcut of stringr::str_glue() without trimming.

str_c_coalesce() tries stringr::str_c() first, and falls back to dplyr::coalesce().

rsplit() splits a string from right.

as_chr() converts expr into character vector.

as_code() converts a vector into R code that generates it.

Usage

glue(..., .sep = "", .envir = parent.frame())

glue_data(.x, ..., .sep = "", .envir = parent.frame(), .na = "NA")

str_c_coalesce(..., sep = "", collapse = NULL)

rsplit(string, pattern = "\\s+", n = 42L)

as_chr(...)

as_code(x)

Arguments

...

expressions

.sep, sep

[character(1): β€˜""’]
Separator used to separate elements.

.envir

[environment: parent.frame()]
Environment to evaluate each expression in. Expressions are evaluated from left to right. If .x is an environment, the expressions are evaluated in that environment and .envir is ignored. If NULL is passed, it is equivalent to emptyenv().

.x

[listish]
An environment, list, or data frame used to lookup values.

.na

[character(1): β€˜NA’]
Value to replace NA values with. If NULL missing values are propagated, that is an NA result will cause NA output. Otherwise the value is replaced by the value of .na.

collapse

Optional string used to combine output into single string. Generally better to use str_flatten() if you needed this behaviour.

string

Input vector. Either a character vector, or something coercible to one.

pattern

Pattern to look for.

The default interpretation is a regular expression, as described in vignette("regular-expressions"). Use regex() for finer control of the matching behaviour.

Match a fixed string (i.e. by comparing only bytes), using fixed(). This is fast, but approximate. Generally, for matching human text, you'll want coll() which respects character matching rules for the specified locale.

Match character, word, line and sentence boundaries with boundary(). An empty pattern, "", is equivalent to boundary("character").

n

Maximum number of pieces to return. Default (Inf) uses all possible split positions.

For str_split(), this determines the maximum length of each element of the output. For str_split_fixed(), this determines the number of columns in the output; if an input is too short, the result will be padded with "".

x

vector


heavywatal/rwtl documentation built on April 29, 2024, 2:02 a.m.