Skip to content

Instantly share code, notes, and snippets.

@martinctc
Last active April 2, 2021 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinctc/e813c03b5f140ba2f2446d9e25ca52e3 to your computer and use it in GitHub Desktop.
Save martinctc/e813c03b5f140ba2f2446d9e25ca52e3 to your computer and use it in GitHub Desktop.
[Loop through Rd files] #R
# Load packages -----------------------------------------------------------
library(tidyverse)
# Path where all Rd files live --------------------------------------------
man_path <-
here::here("man")
# Create a list of all Rd files with full file paths ----------------------
rd_chr <-
dir(man_path) %>%
.[grepl(pattern = "Rd$", x = .)]
man_files <-
rd_chr %>%
paste0(man_path, "/", .)
# Return a list of Rd content from each file ------------------------------
rd_list <-
man_files %>%
purrr::map(function(x){
readLines(x) %>%
paste(collapse = "")
}) %>%
set_names(rd_chr)
# If \value does not exist, return function -------------------------------
names(rd_list[!grepl(pattern = "\\\\value", x = rd_list)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment