Description Usage Arguments Value Examples
Find directories of a family
1 2 3 4 5 6 7 |
parent |
A string giving a single path to the parent directory. The children directories should be nested one level under it. |
regexp |
A regular expression to match the name of the file that defines
the family. You may pass it directly of with "options()", e.g.
|
self |
Include the working directory in the output? Yes: |
A character vector.
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 36 37 38 39 40 41 | library(fs)
library(family)
restore_working_directory <- getwd()
mother <- path(tempdir(), "mother")
siblings <- c("sister", "brother")
neighbour <- "neighbour"
dir_create(path(mother, c(siblings, neighbour)))
# Define the family with any identifying file in the root of each sibling
family_name <- ".us"
family_regexp <- "^[.]us$"
file_create(path(mother, siblings, family_name))
dir_tree(mother, recurse = TRUE, all = TRUE)
# Find the family from anywhere
find_family(parent = mother, regexp = family_regexp)
# Find the family from the parent, the siblings or their neighbours
setwd(path(mother, "neighbour"))
siblings(family_regexp, self = TRUE)
setwd(path(mother, "sister"))
siblings(family_regexp, self = TRUE)
siblings(family_regexp)
# Save typing and reuse code with other families
restore_options <- options(family.regexp = family_regexp)
siblings()
parent()
setwd(parent())
children()
# Cleanup
options(restore_options)
setwd(restore_working_directory)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.