index: Extract an Index of Elements of a Path

Description Usage Arguments Value See Also Examples

Description

Extract the indices of a path. Stands in contrast to front/back in that with the later two the user wants the ends of the path elements (front or bacK) whereas with index the user wants the middle elements of a path.

Usage

1
index(x, inds, collapse = TRUE, ...)

Arguments

x

A parse_path object.

inds

A vector of indices to select from.

collapse

logical. If TRUE the path elements will be collapsed with the "/" separator.

...

ignored.

Value

Returns a vector (either atomic or list of character path elements) of sub-paths.

See Also

Other sub-path manipulation functions: before, front, swap

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
index(list(1:8), 3)
index(list(1:8), 4:6)
index(list(1:8), c(1, 3))

library(magrittr)
files %>%
    parse_path() %>%
    index(c(2, 4:5))

files %>%
    parse_path() %>%
    index(3)

trinker/pathr documentation built on May 31, 2019, 9:41 p.m.