Last active
April 2, 2021 10:52
-
-
Save martinctc/e813c03b5f140ba2f2446d9e25ca52e3 to your computer and use it in GitHub Desktop.
[Loop through Rd files] #R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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