-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckDateRange.R
More file actions
66 lines (41 loc) · 2.09 KB
/
checkDateRange.R
File metadata and controls
66 lines (41 loc) · 2.09 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
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
library("ggplot2")
kitzRich = c(13920,4155)
jt = read.table(file="joinedTablesInc2012_8_12.tsv",
header=T, sep="\t", stringsAsFactors=F)
jt$tran_date<-as.Date(jt$tran_date, format="%m/%d/%Y")
range(jt$tran_date)
tpd = read.table(file="transactionsPerDateKitzDennis.txt", header=T)
tpd$tran_date = as.Date(tpd$tran_date, format="%Y-%m-%d")
ggplot(data=tpd, aes(y=count, x=tran_date))+geom_point()
joinedTab2DateGraph<-function(fileName="./orestar_scrape/transConvertedToTsv/joinedTables.tsv"){
kitzRich = c(13920,4155)
if(grepl(pattern=".csv$", x=fileName)){
jt2 = read.csv(file=fileName, stringsAsFactors=F, strip.white=T)
}else{
jt2 = read.table(file=fileName,
header=T, sep="\t", stringsAsFactors=F)
}
cat("\nRead in",nrow(jt2),"rows of finance data.\n")
jt2 = jt2[jt2$filer_id%in%kitzRich,]
cat("\nFound",nrow(jt2), "rows with contributions for Kitzhaber or Richardson.\n")
da2 = aggregate(x=jt2$amount, by=list(jt2$tran_date), FUN=length)
head(da2)
colnames(da2)<-c("tran_date","count")
tran_date = as.Date(da2$tran_date, format="%m/%d/%Y")
if(is.na(tran_date[1])) tran_date = as.Date(da2$tran_date, format="%Y-%m-%d")
da2$tran_date = tran_date
ggplot(data=da2, aes(y=count, x=tran_date))+geom_point()+ggtitle(fileName)
# ggplot(data=da2[da2$tran_date>as.Date(x="2014-3-1", format="%Y-%m-%d"),], aes(y=count, x=tran_date))+geom_point()
}
AllNeededTables = c("joinedTablesInc2012_8_12.tsv",
"joinedOnMicroMiaInScrapeFolder.tsv",
"joinedTables_with_2014throughSep.tsv")
joinedTab2DateGraph(fileName="joinedTablesInc2012_8_12.tsv")
joinedTab2DateGraph(fileName="joinedTables_from2011.tsv")
joinedTab2DateGraph(fileName="./orestar_scrape/transConvertedToTsv/joinedTables.tsv")
joinedTab2DateGraph(fileName="./joinedOnActual.tsv")
joinedTab2DateGraph(fileName="./joinedOnMicroMia.tsv")
joinedTab2DateGraph(fileName="./joinedOnMicroMiaInScrapeFolder.tsv")
joinedTab2DateGraph(fileName="joinedTables_with_2014throughSep.tsv")
joinedTab2DateGraph(fileName="joinedTablesFullCamp.tsv")
joinedTab2DateGraph(fileName="./raw_committee_transactions.csv")