-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDataGathering.R
More file actions
37 lines (33 loc) · 1.27 KB
/
DataGathering.R
File metadata and controls
37 lines (33 loc) · 1.27 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
#####
# Data Gathering File
# Ben Gaiser and Jeremy Russell
# 7 October 2016
# Purpose: Before starting the data processing, we load certain packages,
# set our directories and load the data frames
#####
# Installing packages
packages <- c('repmis', 'knitr', 'rmarkdown', 'Hmisc', 'ggplot2', 'pastecs', 'RCurl')
for (p in packages) {
if (p %in% installed.packages()) require(p, character.only=TRUE)
else {
install.packages(p)
require(p, character.only=TRUE)
}
}
# Creating a BibTex file
repmis::LoadandCite(packages, file = 'RpackageCitations.bib')
# Setting our working directory
wrkdir <- c('C:/Users/Benji/Desktop/Statistics/Git/Repositories/CSSR',
'~/Hertie School/Fall 2016/CollaborativeSocialScienceDataAnalysis/CSSR')
repmis::set_valid_wd(wrkdir)
# Removing from global environment for better readability
rm(packages, p, wrkdir)
#####
# Loading the data frames
# Alcohol Consumption data set is from fivethirtyeight (https://github.com/fivethirtyeight/data).
# Swiss is a core R data frame
#####
URL <- paste0('https://raw.githubusercontent.com/fivethirtyeight/data/master/alcohol-consumption/drinks.csv')
AlcoholConsumption <- repmis::source_data(URL,
sha1 = 'af869c65cccfc989a3b8c0a21752e4c0ba25bd3d')
swiss <- as.data.frame(swiss)