-
Notifications
You must be signed in to change notification settings - Fork 164
/
mp2.Rmd
117 lines (89 loc) · 2.12 KB
/
mp2.Rmd
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
title: "Put a real title here"
subtitle: "SDS 192: MP2"
author: "Your name"
date: "`r format(Sys.Date(), '%B %e, %Y')`"
output:
html_document:
toc: true
toc_depth: 2
toc_float: true
fig_width: 7
fig_height: 6
fig_caption: true
theme: lumen
df_print: paged
code_folding: show
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
message = FALSE,
echo = TRUE,
warning = FALSE
)
library(tidyverse)
library(sds192)
```
## Introduction
What is this article about?
## Loading the data
```{r, message=FALSE}
library(fec16)
```
To get the full `contributions` table, run this:
```{r, eval=FALSE}
contributions_all <- read_all_contributions()
```
## Some basic EDA
Here are some basic examples of what you can do.
- How many candidates running for what offices?
```{r}
candidates %>%
group_by(cand_election_yr, cand_office, cand_office_st) %>%
summarize(num_candidates = n()) %>%
arrange(desc(num_candidates)) %>%
print(n = Inf)
```
- How many committees [by type](https://classic.fec.gov/finance/disclosure/metadata/CommitteeTypeCodes.shtml)?
```{r}
committees %>%
group_by(cmte_tp) %>%
summarize(
num_committees = n(),
cand_ids = sum(!is.na(cand_id))
) %>%
arrange(desc(num_committees))
```
- What types of contributions are there and where do they go?
Remember that `contributions` is just a sample!
```{r}
contributions %>%
group_by(entity_tp) %>%
summarize(
num_contributions = n(),
total_amount = sum(transaction_amt),
other_ids = sum(!is.na(other_id)),
cand_ids = sum(!is.na(cand_id))
) %>%
arrange(desc(num_contributions))
```
## Analysis
What did you discover?
## Conclusion
What did you learn about the 2016 federal election cycle?
## Word count
```{r word_count, message=FALSE, echo=FALSE}
text_stats()
```
## Standards
In this assignment, we are attempting the following standards:
```{r buttons, echo=FALSE}
standard_button("markdown")
standard_button("aesthetics")
standard_button("wrangling")
standard_button("context")
standard_button("reshape")
standard_button("relational")
standard_button("ethics")
standard_button("github")
```