| bc.str | R Documentation |
The bc.str() function
performs broadcasted string operations on pairs of arrays.
bc.str(x, y, op, ...)
## S4 method for signature 'ANY'
bc.str(x, y, op)
x, y |
conformable atomic arrays of type |
op |
a single string, giving the operator. |
... |
further arguments passed to or from methods. |
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.
The 'C++' code for the Levenshtein edit string distance is based on the code found in https://rosettacode.org/wiki/Levenshtein_distance#C++
broadcast_operators
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.