$ for Searchable objects
1 2 3 4 5
character; pattern with potential match modifiers applied,
missing; never specified
additional arguments. See
For matrices and arrays. If TRUE the result is coerced to the
lowest possible dimension (see the examples). This only works for
extracting elements, not for the replacement. See
replacement value for replacement functions
The methods for searching respect the modifiers applied to both
The values after the extracting methods have been applied:
\[ returns a subset of
x, but which is not Searchable.
\$ return a sinlge element of
[<- are used for subsetting and replacing
zero or more elemenxts of
x. Used with searchable objects,
these operators differ from normal R operations in the following respects:
The search returns elements of the target that matches ANY of the search patterns.
its normal behavior,
\[ does not guarantee the output to have as many
elements as elements to
[ does not return a Searchable object. It is thought that
the return valuable will not be subsequently searched. It is easy to turn
the results into a Searchable object using
Unlike for environments and hashes, no constraints exist for ensuring
uniqueness for names in vectors and lists. These structures may contain
multiple elements with the same name. Normal attempts to extract by name
yield only the first element that matches the name. Using a
Searchable patterns match yields all matching elements.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
# ATOMIC VECTORS: v <- c( a=1, b=2, B=3, c=4, c2=5 ) sv <- searchable(v) # 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 ## Not run: sl[ "B" %>% ignore.case ] "b" %>% sl[.] "B" %>% ignore.case %>% sl[.] ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.