-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path00_requirement.R
49 lines (45 loc) · 1.41 KB
/
00_requirement.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
#===============================================================================
# File-Name: 00-requirements.R
# Date: May 6, 2019
# Paper: Who Leads? Who Follows? Measuring Issue Attention and Agenda Setting
# by Legislators and the Mass Public Using Social Media Data
# Journal: American Political Science Review
# Authors: Pablo Barbera, Andreu Casas, Jonathan Nagler, Patrick J. Egan,
# Richard Bonneau, John Jost, Joshua A. Tucker
# Purpose: check if required packages for the following R scripts exist and install it if needed
# Data In:
# ./data/tweets/text/* & var/lda_results-twokenizer.Rdata &
# var/lda-ouput/*
#===============================================================================
if (!dir.exists(Sys.getenv("R_LIBS_USER"))) {
dir.create(path = Sys.getenv("R_LIBS_USER"), showWarnings = FALSE, recursive = TRUE)
}
# install to local user library path
install_if_missing <- function(pkg) {
if (!requireNamespace(pkg, quietly = TRUE)) {
install.packages(pkg, lib = Sys.getenv("R_LIBS_USER"), repos = "https://cran.rstudio.com/")
}
}
packages <- c(
"argparse",
"cvTools",
'data.table',
"ggdendro",
"ggplot2",
"grid",
"gridExtra",
"gtable",
"ggthemes",
"Matrix",
"reshape",
"scales",
"slam",
"scales",
"shiny",
"tidyverse",
"tm",
"topicmodels"
)
invisible(lapply(packages,
install_if_missing)
)