forked from Hendrik147/HR_Analytics_in_R_book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
purl.R
54 lines (51 loc) · 1.81 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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 and title 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",
"pay-gap",
"stop-appraisals",
"service-desk",
"personality",
"commuting-time",
"organisational-network",
"job-classification",
"masking-data",
"absenteeism-MFG",
"absenteeism-work",
"accidents-work",
"attrition",
"interview-attendance",
"ranking-medical-schools",
"webscraping-linkedin",
"flexdashboards",
"data-science-product")
chapter_numbers <- stringr::str_pad(
string = 1:(length(chapter_titles) + 1),
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)
}