View source: R/PatternMatching.R
WildcardGlobbing | R Documentation |
The selected rows match combined requirements for all variables.
WildcardGlobbing(x, wg, sign = TRUE, invert = "!")
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. |
This function is used by HierarchicalWildcardGlobbing
and WildcardGlobbingVector
and make use of
grepl
and glob2rx
.
Logical vector defining subset of rows.
Øyvind Langsrud
# 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), ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.