-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path_setup.R
84 lines (68 loc) · 1.86 KB
/
_setup.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# what I installed for the slides, in work laptop
if (FALSE) {
install.packages("xaringan")
remotes::install_github("gadenbuie/xaringanExtra")
remotes::install_github("gadenbuie/countdown")
remotes::install_github("hadley/emo")
remotes::install_github("mitchelloharawild/icons")
icons::download_fontawesome()
}
# what I installed in each RStudio Cloud project
if (FALSE) {
install.packages("tidyverse")
install.packages("writexl")
install.packages("readsdmx")
}
# Files and directories ---------------------------------------------------
library(purrr)
rproj <-
c(
"Version: 1.0",
"",
"RestoreWorkspace: No",
"SaveWorkspace: No",
"AlwaysSaveHistory: Default",
"",
"EnableCodeIndexing: Yes",
"UseSpacesForTab: Yes",
"NumSpacesForTab: 2",
"Encoding: UTF-8",
"",
"RnwWeave: Sweave",
"LaTeX: pdfLaTeX"
)
rmds <- c(
"01_intro.Rmd",
"02_dataviz.Rmd",
"03_programming.Rmd",
"04_rmarkdown.Rmd",
"05_goodpractice.Rmd"
)
file_copy2 <- safely(fs::file_copy, otherwise = NULL)
rmds %>%
fs::path("docs/", .) %>%
walk(~ file_copy2("docs/00_template.Rmd", .x, overwrite = FALSE))
rmds %>%
fs::path_ext_remove() %>%
fs::path("exercises/", .) %>%
fs::dir_create()
rmds %>%
fs::path_ext_remove() %>%
fs::path("exercises/", ., "solutions") %>%
fs::dir_create()
rmds %>%
fs::path_ext_remove() %>%
{paste0("exercises/", ., "/", ., ".Rproj")} %>%
purrr::walk(~ writeLines(rproj, .x))
# Render ------------------------------------------------------------------
if (FALSE) {
usethis::use_github_pages(branch = "main", path = "/docs")
}
library(rmarkdown)
render("README.md", output_file = "docs/index.html")
render("docs/00_template.Rmd")
render("docs/01_intro.Rmd")
render("docs/02_dataviz.Rmd")
render("docs/03_programming.Rmd")
render("docs/04_rmarkdown.Rmd")
render("docs/05_goodpractice.Rmd")