-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_common.R
64 lines (52 loc) · 2.07 KB
/
_common.R
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# example R options set globally
#options(width = 60)
# example chunk options set globally
# generate r package bibliography
#bib_packages <- c(.packages(), 'bookdown', 'knitr', 'rmarkdown')
#knitr::write_bib(bib_packages, 'packages.bib')
# set ggplot theme
calculus_palette <- c(
"#782386",
"#ab1866",
"#d1295a",
"#e05b5c",
"#ffcc66"
)
# copy figures from articles
byoc_starch_img <- c("articles/byoc-starch/analysis/figures/protocol_overview.png",
"articles/byoc-starch/analysis/figures/starches_w_bar.jpg",
"articles/byoc-starch/analysis/figures/st2C3.2-mix.jpg",
"articles/byoc-starch/analysis/figures/st1B4-wheat.jpg",
"articles/byoc-starch/analysis/figures/2D2-potato.jpg")
sapply(byoc_starch_img, file.copy, to = "figures/", overwrite = T)
#file.copy("articles/byoc-starch/analysis/figures/protocol_overview.png", "figures/")
# generate/update bibliography only if rendering project
if (!nzchar(Sys.getenv("QUARTO_PROJECT_RENDER_ALL"))) {
quit()
}
library(here)
library(rbbt)
diss_files <- list.files(here(), pattern = ".Rmd|.qmd", full.names = T)
byoc_valid_files <- list.files(here("articles/byoc-valid/07-publication"), pattern = ".Rmd|.qmd", full.names = T)
byoc_starch_files <- list.files(here("articles/byoc-starch/analysis/paper"), pattern = ".Rmd|.qmd", full.names = T)
mb11_file_files <- list.files(here("articles/mb11CalculusPilot/analysis/paper"), pattern = ".Rmd|.qmd", full.names = T)
file_names <- c(diss_files, byoc_valid_files, byoc_starch_files, mb11_file_files)
all_files <- file_names[stringr::str_detect(file_names, "supp-mat|fig_tab", negate = T)]
keys <- bbt_detect_citations(all_files)
bbt_ignore <- keys[grepl("fig-|tbl-", keys)]
try(
if(file.exists(here("book.bib"))) {
bbt_update_bib(here(all_files),
here("book.bib"),
ignore = bbt_ignore,
overwrite = T,
translator = "bibtex")
} else {
refs <- rbbt::bbt_detect_citations(all_files)
bbt_write_bib(here("book.bib"),
keys = keys,
ignore = bbt_ignore,
overwrite = T,
translator = "bibtex")
}
)