-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_____RepRes_analysis.R
72 lines (54 loc) · 2.48 KB
/
render_____RepRes_analysis.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
################################################################################
# ABOUT THIS SCRIPT: 'render_report_____readthedown.R'
################################################################################
# DESCRIPTION: This script renders the script 'RepRes_analysis.Rmd'
# to produce the 'readthedown' version of the report
# that gets exported as 'Report(version:readthedown).html'
# at the 'docs' folder of the working directory.
# PLAN: 1. Checks if the required file, 'RepRes_analysis.Rmd'
# exists at the working directory.
# If it doesn't, the execution of the script terminates.
# 2. Checks if the 'docs' folder exists at the working directory.
# If it doesn't, it creates the folder.
# 3. Renders the 'RepRes_analysis.Rmd' file
# to produce 'Report(version:readthedown).html' file
# and exports it at the 'docs' directory.
################################################################################
# PRODUCE THE 'readthedown' VERSION OF THE REPORT
################################################################################
# Load All Required Libraries
require(rmarkdown)
require(rmdformats)
# Check if the 'RepRes_analysis.Rmd' file exists at the working directory.
if ( !file.exists("RepRes_analysis.Rmd") ) {
stop(
"\n",
"The required file 'RepRes_analysis.Rmd' ", "\n",
"wasn't found at the working directory. ", "\n",
"The execution of the script terminated ", "\n",
"without creating the file ", "\n",
"'Report(version:readthedown).html'.", "\n",
"Download the required file from the following link: ", "\n",
"\t", "https://github.com/jzstats/Reproducible-Research--2nd-Assignment/blob/master/RepRes_analysis.Rmd", "\n",
"and then execute the script again. ", "\n",
"\n"
)
}
# Create the output directory (if it doesn't exists already)
if (!dir.exists("docs")) {
dir.create("docs")
}
# Render the 'RepRes_analysis.Rmd' file
# to produce the 'readthedown' version of the report
# and exports the 'Report(version:readthedown).html' file
# at the 'docs' directory.
render(
input = "RepRes_analysis.Rmd",
output_format = readthedown(
toc_depth = 3,
code_folding = "hide"
),
output_file = "Report.html",
output_dir = "docs"
)
# THE END ######################################################################