| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/path_select.R |
| 3 |
\name{path_select_components} |
| 4 |
\alias{path_select_components} |
| 5 |
\title{Select path components by their position/index.} |
| 6 |
\usage{ |
| 7 |
path_select_components(path, index, from = c("start", "end")) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{path}{A path of class \code{fs_path}.} |
| 11 |
|
| 12 |
\item{index}{An integer vector of path positions. (A negative index will work |
| 13 |
according to R's usual subsetting rules.)} |
| 14 |
|
| 15 |
\item{from}{A character of either \code{"start"} or \code{"end"} to choose if indexing |
| 16 |
should start from the first or last component of the \code{path}.} |
| 17 |
} |
| 18 |
\value{ |
| 19 |
An \code{fs_path} object, which is a character vector that also has class |
| 20 |
\code{fs_path}. |
| 21 |
} |
| 22 |
\description{ |
| 23 |
\code{path_select_components()} allows to select individual components from |
| 24 |
an \code{fs_path} object via their index. |
| 25 |
} |
| 26 |
\details{ |
| 27 |
\code{path_select_components()} is vectorized. |
| 28 |
} |
| 29 |
\examples{ |
| 30 |
path <- fs::path("some", "simple", "path", "to", "a", "file.txt") |
| 31 |
|
| 32 |
path_select_components(path, 1:3) |
| 33 |
|
| 34 |
path_select_components(path, 1:3, "end") |
| 35 |
|
| 36 |
path_select_components(path, -1, "end") |
| 37 |
|
| 38 |
path_select_components(path, 6) |
| 39 |
} |