-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_install_packages.R
69 lines (61 loc) · 1.45 KB
/
run_install_packages.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
################################################################################
# run_install_packages.R
#
# @author: Hair Albeiro Parra Barrera
# @author: Xiao Xue
# @author: Kriti Bhaya
# @author: Prateek
#
# This R script is designed to load specified packages and install them if they
# are not already installed.
################################################################################
################
### 0. Setup ###
################
# load required scripts
library("here")
source(here("functions", "modelling.R"))
################
### 0. Setup ###
################
# List of packages to automatically install
proj_packages <- c(
"xts",
"zoo",
"TTR",
"here",
"stats",
"leaps",
"rvest",
"dplyr",
"caret",
"glmnet",
"Metrics",
"quadprog",
"quantmod",
"forecast",
"data.table",
"tidyverse",
"tidyquant",
"PerformanceAnalytics"
)
####################
### 1. Functions ###
####################
# Load required packages
f_load_packages <- function(package_list) {
for (package in package_list) {
# Check if the package is already installed
if (!requireNamespace(package, quietly = TRUE)) {
# If not installed, install the package with dependencies
install.packages(package, dependencies = TRUE)
}
# Load the package
library(package, character.only = TRUE)
}
}
###############
### 2. Main ###
###############
# Call the function to load packages
f_load_packages(proj_packages)