-
Notifications
You must be signed in to change notification settings - Fork 1
/
prep.R
32 lines (29 loc) · 968 Bytes
/
prep.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
###############################################################################
## File for preparing R
## by: Alexander Sacharow
###############################################################################
# Clear Global environment
rm(list=ls())
# Collect packages/libraries we need:
packages <- c("readxl", "plyr" ,"dplyr", "ggplot2", "reshape2", "scales",
"stargazer", "Hmisc", "xtable")
# package and why it is needed
# readxl: import excel files
# plyr: mapvalues function
# dyplyr: data manipulation
# ggplot: plots (e.g. density)
# reshape2: melt function
# scales: label transformation in ggplot
# Hmisc: Correlation table
# xtable: create latex table
# install packages if not installed before
for (p in packages) {
if (p %in% installed.packages()[,1]) {
require(p, character.only=T)
}
else {
install.packages(p, repos="http://cran.rstudio.com", dependencies = TRUE)
require(p, character.only=T)
}
}
rm(p, packages)