index {jqr} | R Documentation |
index and related functions
Description
index and related functions
Usage
index(.data, ...)
index_(.data, ..., .dots)
indexif(.data, ...)
indexif_(.data, ..., .dots)
dotindex(.data, ...)
dotindex_(.data, ..., .dots)
Arguments
.data |
input. This can be JSON input, or an object of class
|
... |
Comma separated list of unquoted variable names |
.dots |
Used to work around non-standard evaluation |
dots |
dots |
Details
-
index
/index_
- queries like:.[]
,.[0]
,.[1:5]
,.["foo"]
-
indexif
/indexif_
- queries like:.["foo"]?
-
dotindex
/dotindex_
- queries like:.[].foo
,.[].foo.bar
Examples
str <- '[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]'
str %>% index
'{"name":"JSON", "good":true}' %>% indexif(name)
'{"name":"JSON", "good":true}' %>% indexif(good)
'{"name":"JSON", "good":true}' %>% indexif(that)
'{"a": 1, "b": 1}' %>% index
'[]' %>% index
'[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]' %>% index(0)
'["a","b","c","d","e"]' %>% index(2)
'["a","b","c","d","e"]' %>% index('2:4')
'["a","b","c","d","e"]' %>% index('2:5')
'["a","b","c","d","e"]' %>% index(':3')
'["a","b","c","d","e"]' %>% index('-2:')
str %>% index %>% select(bad = .name)
'[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]' %>%
dotindex(name)
'[{"name":"JSON", "good":true}, {"name":"XML", "good":false}]' %>%
dotindex(good)
'[{"name":"JSON", "good":{"foo":5}}, {"name":"XML", "good":{"foo":6}}]' %>%
dotindex(good)
'[{"name":"JSON", "good":{"foo":5}}, {"name":"XML", "good":{"foo":6}}]' %>%
dotindex(good.foo)
[Package jqr version 1.3.3 Index]