-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclean-data-week4-quiz-scratch.R
More file actions
33 lines (26 loc) · 1.33 KB
/
clean-data-week4-quiz-scratch.R
File metadata and controls
33 lines (26 loc) · 1.33 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
url <- 'https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06hid.csv'
download.file(url, destfile='hid.csv',method='curl')
#code book https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2FPUMSDataDict06.pdf
hid <- read.csv('hid.csv')
strsplit(names(hid), 'wgtp')[[123]]
url <- 'https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2FGDP.csv'
download.file(url, destfile='FGDBP.csv', method='curl')
fgdbp <- read.csv('FGDBP.csv', stringsAsFactors = FALSE)
gdb <- as.numeric(gsub(",", "", fgdbp[5:194,5]))
mean(gdb)
countryNames <- fgdbp[5:194,4]
grep("^United", countryNames)
download.file('https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2FGDP.csv', destfile = 'FGDP.csv', method='curl')
FGDP <- read.csv('FGDP.csv', stringsAsFactors = FALSE)
FGDP_clean <- FGDP[5:194,]
FGDP_clean$rank = as.numeric(FGDP_clean$Gross.domestic.product.2012)
download.file('https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2FEDSTATS_Country.csv', destfile = 'STATS_Country.csv', method='curl')
SC <- read.csv('STATS_Country.csv')
merged <- merge(FGDP_clean, SC, by.x="X", by.y="CountryCode")
length(grep("year end: +[jJ]une", merged$Special.Notes, value=TRUE))
library(quantmod)
amzn = getSymbols("AMZN",auto.assign=FALSE)
sampleTimes = index(amzn)
in2012 <- sampleTimes[format(sampleTimes, "%Y") == "2012"]
length(in2012)
sum(weekdays(in2012) == "Monday")