-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.R
81 lines (72 loc) · 2.11 KB
/
setup.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
## Run this script with `source(here::here("setup.R"))`
options(stringsAsFactors = F)
## Add any R packages you require.
## Here are some we will use in 811:
requires <- c("tidyverse", # tidyverse includes dplyr and ggplot2
"ggridges",
"broom",
"tidytext",
"tm",
"stm",
"wordcloud",
"grid",
"gridExtra",
"magrittr",
"foreign",
"readstata13",
"tidytext",
"stm",
"topicmodels",
"textfeatures",
"cleanNLP", ## https://statsmaths.github.io/cleanNLP/
"maps",
"sf",
"here",
"rvest",
"remotes",
"knitr")
## Install any you don't have
to_install <- c(requires %in% rownames(installed.packages()) == FALSE)
install.packages(c(requires[to_install], "NA"), repos = "https://cloud.r-project.org/" )
rm(requires, to_install)
## Load all required R packages
library(tidyverse)
library(broom)
library(ggplot2); theme_set(theme_bw())
library(magrittr)
library(tidytext)
library(tm)
library(stm)
library(wordcloud)
library(gridExtra)
library(grid)
library(foreign)
library(readstata13)
library(tidytext)
library(stm)
library(topicmodels)
library(textfeatures)
library(cleanNLP) ## https://statsmaths.github.io/cleanNLP/
library(maps)
library(sf)
library(here)
library(knitr)
library(ggridges)
library(rvest)
## Sets defaults for R chunks
knitr::opts_chunk$set(echo = TRUE, # echo = TRUE means that your code will show
warning = FALSE,
message = FALSE,
fig.align = "center",
fig.path= 'Figs/', ## where to save figures
fig.height = 3,
fig.width = 3)
# Xaringan
if(!"xaringan" %in% rownames(installed.packages() ) ){
remotes::install_github('yihui/xaringan')
}
if(!"xaringanthemer" %in% rownames(installed.packages() ) ){
remotes::install_github('gadenbuie/xaringanthemer')
}
library("xaringan")
library("xaringanthemer")