bc.str: Broadcasted String Operations

bc.strR Documentation

Broadcasted String Operations

Description

The bc.str() method 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 vectors/arrays of type character.

op

a single string, giving the operator.
Supported concatenation operators: +.
Supported relational operators: ==, !=.
Supported distance operators: levenshtein, lcss.
"levenshtein" is a distance measure of remoteness (i.e. greater distance = higher levenshtein).
"lcss" stands for Longest Common Sub-String, and is a distance measure of closeness (i.e. smaller distance = higher lcss).

...

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 distances:
x <- setNames(month.name, month.name) |> vector2array(1L)
y <- setNames(month.abb, month.abb) |> vector2array(2L)
bc.str(x, y, "levenshtein") # levenshtein
bc.str(x, y, "lcss") # longest common sub-string

broadcast documentation built on Aug. 20, 2026, 9:08 a.m.

Related to bc.str in broadcast...