forked from moderndive/ModernDive_book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpurl.R
36 lines (34 loc) · 1.09 KB
/
purl.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
if(!dir.exists("docs/scripts")){
dir.create("docs")
dir.create("docs/scripts")
}
# For Chapter 5
solutions_shown <- c('')
show_solutions <- function(section){
return(solutions_shown == "ALL" | section %in% solutions_shown)
}
# Note order matters here:
chapter_titles <- c("getting-started",
"visualization",
"wrangling",
"tidy",
"regression",
"multiple-regression",
"sampling",
"confidence-intervals",
"hypothesis-testing",
"inference-for-regression",
"tell-your-story-with-data")
chapter_numbers <- stringr::str_pad(
string = 1:(length(chapter_titles)),
width = 2,
side = "left",
pad = "0"
)
for(i in seq_len(length(chapter_numbers))){
Rmd_file <- stringr::str_c(chapter_numbers[i], "-",
chapter_titles[i], ".Rmd")
R_file <- stringr::str_c("docs/scripts/", chapter_numbers[i],
"-", chapter_titles[i], ".R")
knitr::purl(Rmd_file, R_file)
}