forked from OHI-Science/ohimanual
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_plan.r
64 lines (52 loc) · 1.77 KB
/
make_plan.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
# load libraries ----
library(knitr) # install.packages("knitr")
library(rmarkdown)
library(stringr)
# Also required if you get the pdflatex error: www.tug.org/mactex
# set variables ----
title = 'The Ocean Health Index Planning Guide' # change title??
wd = '~/github/ohimanual/2_plan'
in_md = c(
#'Phase_2.md', # currently this file is in 0_orientation; JSL not sure it fits here?
'Understand_Requirements_for_Assessment.md',
'Funding.md',
'Assembling_team.md', # --> Developing; fix
'Data_Requirements.md',
'Planning_and_Partnering.md',
'Who_Should_Be_Involved.md',
'Conducting_a_Stakeholder_Analysis.md',
'Introducing_Concept_to_Stakeholders.md',
'Considerations_for_Joint_Planning.md',
'Vision.md',
'Objectives.md',
'Spatial_Scale.md',
'Strategy.md',
'Costs_and_Financial_Planning.md',
'Adaptive_Management.md')
# summarzing ending # add some kind of summary
out_md = 'ohi-plan.md' # <- this is the output "final" file.
# helper functions ----
cat_md = function(
files_md = setdiff(list.files(getwd(), glob2rx('*.md')), out_md),
out_md = '_all_.md'){
if (file.exists(out_md)) unlink(out_md)
cat('---\n', 'title: ', title, '\n---\n\n', sep='', file=out_md, append=T)
for (md in files_md){
cat(paste(c(readLines(md),'',''), collapse='\n'), file=out_md, append=T)
}
}
# concatenate md ----
setwd(wd)
cat_md(in_md, out_md)
pfx = tools::file_path_sans_ext(out_md)
# render pdf ----
render(
out_md,
pdf_document(
toc = T, toc_depth = 3, number_sections = T,
fig_width = 6.5, fig_height = 4.5, fig_crop = TRUE,
fig_caption = T, highlight = "default", template = "default",
keep_tex = F, latex_engine = "pdflatex",
includes = NULL, pandoc_args = NULL),
clean=T, quiet=F,
output_file = paste0(pfx, '.pdf'))