WildcardGlobbing {SSBtools} | R Documentation |
Row selection by wildcard/globbing
Description
The selected rows match combined requirements for all variables.
Usage
WildcardGlobbing(x, wg, sign = TRUE, invert = "!")
Arguments
x |
data.frame with character data |
wg |
data.frame with wildcard/globbing |
sign |
When FALSE, the result is inverted. |
invert |
Character to invert each single selection. |
Details
This function is used by HierarchicalWildcardGlobbing
and WildcardGlobbingVector
and make use of
grepl
and glob2rx
.
Value
Logical vector defining subset of rows.
Author(s)
Øyvind Langsrud
Examples
# Create data input
data(precip)
data(mtcars)
x <- data.frame(car = rownames(mtcars)[rep(1:NROW(mtcars), each = 35)], city = names(precip),
stringsAsFactors = FALSE)
# Create globbing/wildcards input
wg <- data.frame(rbind(c("Merc*", "C*"), c("F*", "??????"), c("!?????????*", "!???????*")),
stringsAsFactors = FALSE)
names(wg) <- names(x)
# Select the following combinations:
# - Cars starting with Merc and cities starting with C
# - Cars starting with F and six-letter cities
# - Cars with less than nine letters and cities with less than seven letters
x[WildcardGlobbing(x, wg), ]
[Package SSBtools version 1.5.2 Index]