bc.str: Broadcasted String Operations

bc.strR Documentation

Broadcasted String Operations

Description

The bc.str() function performs broadcasted string operations on pairs of arrays.

Usage

bc.str(x, y, op, ...)

## S4 method for signature 'ANY'
bc.str(x, y, op)

Arguments

x, y

conformable atomic arrays of type character.

op

a single string, giving the operator.
Supported concatenation operators: +.
Supported relational operators: ==, !=.
Supported distance operators: levenshtein.

...

further arguments passed to or from methods.

Value

For concatenation operation:
A character array as a result of the broadcasted concatenation operation.

For relational operation:
A logical array as a result of the broadcasted relational comparison.

For distance operation:
An integer array as a result of the broadcasted distance measurement.

References

The 'C++' code for the Levenshtein edit string distance is based on the code found in https://rosettacode.org/wiki/Levenshtein_distance#C++

See Also

broadcast_operators

Examples


# string concatenation:
x <- array(letters, c(10, 2, 1))
y <- array(letters, c(10,1,1))
bc.str(x, y, "+")


# string (in)equality:
bc.str(array(letters), array(letters), "==")
bc.str(array(letters), array(letters), "!=")


# string distance (Levenshtein):
x <- array(month.name, c(12, 1))
y <- array(month.abb, c(1, 12))
out <- bc.str(x, y, "levenshtein")
dimnames(out) <- list(month.name, month.abb)
print(out)

broadcast documentation built on Sept. 15, 2025, 5:08 p.m.

Related to bc.str in broadcast...