retrieve_rmds {accessrmd}R Documentation

Find Rmd files within a provided file structure.

Description

Recursively searches file structure for Rmarkdown files. Returns the found Rmd relative paths.

Usage

retrieve_rmds(search_dir = ".", recurse = TRUE, to_txt = FALSE)

Arguments

search_dir

The directory to search. Defaults to ".".

recurse

Defaults to TRUE. Should child directories be searched or not.

to_txt

Defaults to FALSE. If TRUE, writes found rmd paths in a txt to the search_dir.

Value

Relative paths to all found Rmd files.

Examples


# Create a test directory
dir.create("parent")
dir.create("parent/child")

# Create some rmds to find
# An empty vector to collect file names
nm_vec <- character()
# create numbered file names
for (num in 1:6) {
  nm <- paste0(num, "-test.Rmd")
  nm_vec <- append(nm_vec, nm)
}
# Create some files in parent & child directories
file.create(paste0("parent/", nm_vec[1:3]))
file.create(paste0("parent/child/", nm_vec[4:6]))

# Return all Rmd files
retrieve_rmds("parent")

# tidy up environment
unlink(c("parent", "child"), recursive = TRUE)



[Package accessrmd version 1.0.0 Index]