Description Usage Arguments Value See Also Examples
front
- Extract the first n elements of a path. Similar to
head
(uses head
under the hood).
Compare the defualt settings to basename
and
dirname
.
back
- Extract the first n elements of a path. Similar to
tail
(uses tail
under the hood).
1 2 3 |
x |
A |
n |
A single integer. If positive, size for the resulting object: number
of elements for a vector. If negative, all but the |
collapse |
logical. If |
... |
ignored. |
Returns a vector (either atomic
or list
of
character
path elements) of sub-paths.
Other sub-path manipulation functions: before
,
index
, swap
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 | front(list(1:8), 3)
front(list(1:8), -3)
back(list(1:8), 3)
back(list(1:8), -3)
library(magrittr)
files %>%
parse_path() %>%
front()
files %>%
parse_path() %>%
front(3)
files %>%
parse_path() %>%
back()
files %>%
parse_path() %>%
back(3)
## Compare to basename/dirname
(fls <- file.path("","p1","p2","p3", c("file.pdf", "file.txt", "file.Rmd")))
basename(fls)
fls %>%
parse_path() %>%
back()
dirname(fls)
fls %>%
parse_path() %>%
front()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.