searchable makes a named object a Searchable target, optionally
specifying the default search options.searchable(object, type = "std", ...)## S3 method for class 'Searchable':
show(object)
?pattern for details.stringr and stringi are general purpose string manipulations
library allowing flexible search and pattern matching against character
strings. The searchable package applies this type of matching
to objects' names using the standard [ accessor. Thus, searchable(sv)[ regex('b') ]
returns objects the subset of whose names contain 'b'.
Unlike stringr/i, searchable allows search specification
to applied to either the search pattern or search target.
When applied to the target, a default search method is configured. All
subsequent searches of the searchable target will use this default pattern.
The search method can be specified with the type argument of the
searchable function or any of match-modifying functions,
e.g. fixed, regex, coll, ignore.case, etc.
See examples.
When modifiers are applied to both target and pattern, modifers applied to the pattern take precedence and the target's modifiers are disabled.
searchable is designed to be minimally invase. When no search types
or options are specified, mathcing defaults to R's normal behavior.Here are the other differnece from standard R operations:
$and
i. Input elements that do not match a named element of
x return NA. Because of the indeterminant number of
matches given a pattern search against a searchable object,
there is no guarantee that a search pattern have a match. If no
matches are found, a zero-length object is returned. (This may change
to NA to be more consisitent.)
searchable can be used to replace objects as well. See ?extract
for additional exemples.
}
Multiple dimension ojects such as data.frames, data.tables, matrices and
arrays are not supported at this time.
}
# FLEXIBLY FIND ELEMENTS BY NAME sv[ regex('c') ] sv[ fixed('c') ]
sv[ ignore.case('b') ]
# FLEXIBLY REPLACEMENT ELEMENTS BY NAME sv[ regex('c.?') ] <- "3rd"
# SET DEFAULT SEARCH FOR TARGET/OBJECT sv <- searchable(v, case_insensitive = TRUE ) sv['b'] sv['B']
sv <- regex(sv) sv['c']
sv <- ignore.case(sv) sv['b'] sv['c'] # st
# USE ON (RECURSIVE) LISTS: l <- list( a=1, b=2, c=3 ) sl <- searchable(l) sl["b"] sl[ ignore.case("B") ]
# USE WITH MAGRITTR
sl[ "B" %>% ignore.case ]
"b" %>% sl[.]
"B" %>% ignore.case %>% sl[.]
extract
stri_detect_regex
reverse.lookup
[ and
[<- operators. The following search types are supported:stdstandard R matching, the defaultregexfor regular expression matching,fixedfor fixed string matching,collfor collation matching,Class Searchable objects allow customizations of how R's
[ operator match objects' names.