-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathglobal.R
More file actions
94 lines (75 loc) · 2.49 KB
/
global.R
File metadata and controls
94 lines (75 loc) · 2.49 KB
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
###########################-
#### REQUIRED PACKAGES ####
###########################-
required_packages <- c("shiny", "markdown", "haven", "here", "labelled", "sjlabelled", "DT", "ggplot2", "naniar",
"readxl", "writexl", "tm", "shinyBS", "shinycssloaders", "shinydashboard", "shinyWidgets",
"tidyverse", "corrplot", "broom", "viridis", "plotly", "psych", "car", "randomForest")
for (packageName in required_packages) {
if (!requireNamespace(packageName)) {
install.packages(packageName)
}
}
###########################-
#### SETUP.R LIBRARIES ####
###########################-
library(haven)
library(here)
library(labelled)
library(sjlabelled)
library(readxl)
library(writexl)
library(tm)
library(plyr)
############################-
#### LIBRARY COLLECTION ####
############################-
library(shiny)
library(markdown)
library(DT)
library(ggplot2) #covered by tidyverse, remove later, maybe?
library(naniar)
library(shinyBS)
library(shinycssloaders)
library(shinydashboard)
library(shinyWidgets)
library(tidyverse)
library(corrplot)
library(broom)
library(viridis)
library(plotly)
library(psych)
library(car)
library(randomForest)
# library(gtsummary)
# library(leaflet)
# library(rnaturalearth)
# library(sf)
# library(dplyr)
# library(rstatix)
# library(scales)
# library(skimr)
# library(visdat)
##########################################-
#### SETTING SEED FOR REPRODUCIBILITY ####
##########################################-
set.seed(20241211)
##########################################################-
#### RUN THIS LINE ON THE VERY FIRST EXECUTION ####
#### IF NO FILES OTHER THE RDS's ARE SAVED ####
#### INTO THE FOLDER 'WDS_Dataset'. ####
#### THIS CODE WILL CREATE EVERY OTHER NECESSARY FILE ####
##########################################################-
# source(file.path("Support_Files/WVS_Wave7_Setup.R"), local = TRUE)
#################################-
#### WAVE 7 - DATA WRANGLING ####
#################################-
source(file.path("Support_Files/WVS_Wave7_Wrangling.R"), local = TRUE)
###########################-
#### SUPPORT FUNCTIONS ####
###########################-
source(file.path("Support_Files/functions.R"), local = TRUE)
# Create global variable
grouped_questions <- get_groupedQs_I()
# list of questions grouped by their category minus ignored questions
grouped_minus_ignored <- lapply(grouped_questions, function(x)
x[!grepl(paste0("\\b(", paste(ignored_questions, collapse = "|"), ")\\b"), x)])