Description Usage Arguments Value See Also Examples
Replace the elements of a path. Note either a index (use inds
) or regex
(use pattern
) based approach is used to identify the indices to replace.
The more specific swap_index
or swap_regex
can be used to be
more targetted, transparent, pipeable, and efficient.
1 2 3 4 5 |
x |
A |
inds |
Indices to replace. |
replacement |
A value to replace the indentified indices with. |
pattern |
A character string containing a regular expression (or
character string for |
collapse |
logical. If |
... |
ignored. |
Returns a vector (either atomic
or list
of
character
path elements) of swapped paths.
Other sub-path manipulation functions: before
,
front
, index
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | swap(list(1:8), inds = c(2, 4), "REPLACED VALUE")
swap(list(1:8), pattern = "[238]", replacement = "REPLACED VALUE")
library(magrittr)
files %>%
parse_path() %>%
swap(1, "MyFile")
files %>%
parse_path() %>%
swap_index(3, "textMining")
files %>%
parse_path() %>%
swap_regex("^qdap$", "textMining")
files %>%
parse_path() %>%
swap_regex("\\.R$", "function.R")
files %>%
parse_path() %>%
swap_regex("^(P|R)", "oops")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.