forked from Sta323-Sp19/hw7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhw7.Rmd
85 lines (60 loc) · 1.18 KB
/
hw7.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
---
title: "Sta 523 - Homework 7"
author: [Your names here]
output: html_document
---
### Setup
```{r setup, message=FALSE}
library(sf)
library(dplyr)
library(ggplot2)
```
## Task 1 - Clean and Merge Data
### Parking Violation Data
```{r}
nyc = readRDS("/data/nyc_parking/nyc_parking_2014_cleaned.rds")
head(nyc)
```
### Geocoding Data
```{r warning=FALSE}
pluto = read_sf("/data/nyc_parking/pluto_manhattan/MNMapPLUTO.shp")
head(pluto$Address)
plot(st_geometry(pluto))
```
### Clean data
```{r}
nyc_ticket = nyc %>%
filter(violation_precinct >= 1, violation_precinct <= 34) %>%
transmute(
violation_precinct = violation_precinct,
address = paste(house_number, street_name) %>% tolower()
)
```
```{r}
pluto_xy = pluto %>%
st_centroid() %>%
transmute(address = Address %>% tolower()) %>%
cbind(., st_coordinates(.)) %>%
as_tibble() %>%
select(-geometry)
plot(select(pluto_xy, -address), pch=16, cex=0.1)
```
### Merge data
```{r}
match = inner_join(
pluto_xy,
nyc_ticket,
by = "address"
)
```
```{r}
ggplot(match, aes(x=X, y=Y, color=as.factor(violation_precinct))) +
geom_point()
```
## Task 2 - Modeling
### Setup
```{r}
```
### Modeling
```{r}
```