-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.r
97 lines (83 loc) · 2.54 KB
/
init.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
85
86
87
88
89
90
91
92
93
94
95
96
#library(packrat)
#packrat::init(options = list(ignored.packages = c()))
# packrat::snapshot()
# packify()
# packrat::bundle(project = NULL, file = NULL, include.src = TRUE,
# include.lib = FALSE, include.bundles = TRUE,
# include.vcs.history = TRUE, overwrite = TRUE, omit.cran.src = TRUE)
Install_And_Load <- function(Required_Packages)
{
Remaining_Packages <- Required_Packages[!(Required_Packages %in% installed.packages()[,"Package"])];
if(length(Remaining_Packages))
{
install.packages(Remaining_Packages,dependencies=TRUE);
}
for(package_name in Required_Packages)
{
library(package_name,character.only=TRUE,quietly=TRUE);
}
}
requiredPackages = c('packrat'
,'rprojroot'
,'ggplot2'
,'dplyr'
,'leaflet'
,'DT'
,'stringr'
,'knitr'
,'markdown'
,'rmarkdown'
,'sf'
,'ggmap'
,'Rcpp'
,'bookdown'
,'purrr'
,'bibtex'
,'anchors'
,'digest'
,'backports'
,'devtools'
,'yaml'
,'RgoogleMaps'
)
Install_And_Load(requiredPackages)
devtools::install_github('rstudio/rmarkdown')
#
if (!require('rmarkdown', character.only=TRUE)) {
install_version("rmarkdown", version = 1.9)
library(rmarkdown)
} else {
library(rmarkdown)
}
if (!require('knitr', character.only=TRUE)) {
devtools::install_github("haozhu233/kableExtra")
library(knitr)
} else {
library(knitr)
}
if (!require('kableExtra', character.only=TRUE)) {
install_version("kableExtra", version = 1.9)
library(kableExtra)
} else {
library(kableExtra)
}
if (!require('rmarkdown', character.only=TRUE)) {
install_version("rmarkdown", version = 1.9)
library(rmarkdown)
} else {
library(rmarkdown)
}
if (!require('tinytex', character.only=TRUE)) {
devtools::install_github('yihui/tinytex')
library(tinytex)
} else {
library(tinytex)
}
# if this fails, try installing (Active) Perl on your computer and re-try. - https://www.perl.org/get.html
# https://github.com/yihui/tinytex/issues/45
if (tinytex:::is_tinytex()){
print("TinyTeX already installed! -- No forced installation committed.")
} else{
print("Installing TinyTeX within the TinyTeX R package (tinytex::install_tinytex())")
tinytex::install_tinytex()
}