repurposing corr_data.R into a function to allow required params to be passed in

This commit is contained in:
Tanushree Tunstall 2022-01-29 17:24:15 +00:00
parent 7317156bba
commit 5346431256
4 changed files with 126 additions and 50 deletions

View file

@ -8,11 +8,35 @@
require("getopt", quietly = TRUE) # cmd parse arguments
if (!require ("DT")){
install.packages("DT")
library(DT)
}
if (!require ("plyr")){
install.packages("plyr")
library(plyr)
}
if (!require("tidyverse")) {
install.packages("tidyverse", dependencies = TRUE)
library(tidyverse)
}
#---------------------------
# covered by tidyverse
# if (!require("ggplot2")) {
# install.packages("ggplot2", dependencies = TRUE)
# library(ggplot2)
# }
# if (!require ("dplyr")){
# install.packages("dplyr")
# library(dplyr)
# }
#-----------------------------
if (!require("shiny")) {
install.packages("shiny", dependencies = TRUE)
library(shiny)
@ -33,26 +57,6 @@ if (!require("ggridges")) {
library(ggridges)
}
# if (!require("ggplot2")) {
# install.packages("ggplot2", dependencies = TRUE)
# library(ggplot2)
# }
# if (!require ("dplyr")){
# install.packages("dplyr")
# library(dplyr)
# }
if (!require ("DT")){
install.packages("DT")
library(DT)
}
if (!require ("plyr")){
install.packages("plyr")
library(plyr)
}
# Install
#if(!require(devtools)) install.packages("devtools")
#devtools::install_github("kassambara/ggcorrplot")
@ -188,3 +192,17 @@ map(paste0(func_path, source_files), source) # source all your R scripts!
# set plot script dir
plot_script_path = "~/git/LSHTM_analysis/scripts/plotting/"
##################################################
# Function name clashes with plyr and dplyr
# # loading dplyr after plyr causes issues
# if("dplyr" %in% (.packages())){
# detach("package:dplyr", unload=TRUE)
# detach("package:plyr", unload=TRUE)
# }
# library(plyr)
# library(dplyr)
# another solution is to requireNamespace() instead of library()
# so its function names don't collide with dplyr's.