-
Notifications
You must be signed in to change notification settings - Fork 0
/
DPS_Code_4.R
217 lines (207 loc) · 12.5 KB
/
DPS_Code_4.R
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# Installing and load ggplot2 package
#install.packages("ggplot2")
library(ggplot2)
# Code 4.1 starts here
setwd("C:/Users/akunna1/Desktop/DPS_Files_Akunna") #can modify this to any directory
# Importing the CSV file into a data frame
disrep_data <- read.csv("dc_parcels_dus_20230724_discrepancy.csv")
View(disrep_data)
# Code 4.2a starts here
# Working discrep_addr_city, discrep_addr_landuse, discrep_city_landuse columns
# Removing where discrep_addr_city, discrep_addr_landuse, discrep_city_landuse = 0
# for Where du_est_city = 1
# discrep_addr_city column:
filtered_data_1 <- subset(disrep_data, du_est_city == 1 & discrep_addr_city != 0) #removing where discrep_addr_city = 0
discrep_addr_city_counts_1 <- table(filtered_data_1$discrep_addr_city)
discrep_addr_city_counts_1_df <- as.data.frame(discrep_addr_city_counts_1)
colnames(discrep_addr_city_counts_1_df) <- c("discrep_addr_city", "Frequency")
ggplot(discrep_addr_city_counts_1_df, aes(x = discrep_addr_city, y = Frequency)) +
geom_bar(stat = "identity", fill = "blue") +
labs(title = "Discrep_addr_city Frequency for du_est_city = 1",
x = "discrep_addr_city",
y = "Frequency")
# discrep_addr_landuse column:
filtered_data_1 <- subset(disrep_data, du_est_city == 1 & discrep_addr_landuse != 0)
discrep_addr_landuse_counts_1 <- table(filtered_data_1$discrep_addr_landuse)
discrep_addr_landuse_counts_1_df <- as.data.frame(discrep_addr_landuse_counts_1)
colnames(discrep_addr_landuse_counts_1_df) <- c("discrep_addr_landuse", "Frequency")
ggplot(discrep_addr_landuse_counts_1_df, aes(x = discrep_addr_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "blue") +
labs(title = "Discrep_addr_landuse Frequency for du_est_city = 1",
x = "discrep_addr_landuse",
y = "Frequency")
# discrep_city_landuse column:
filtered_data_1 <- subset(disrep_data, du_est_city == 1 & discrep_city_landuse != 0)
discrep_city_landuse_counts_1 <- table(filtered_data_1$discrep_city_landuse)
discrep_city_landuse_counts_1_df <- as.data.frame(discrep_city_landuse_counts_1)
colnames(discrep_city_landuse_counts_1_df) <- c("discrep_city_landuse", "Frequency")
ggplot(discrep_city_landuse_counts_1_df, aes(x = discrep_city_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "blue") +
labs(title = "Discrep_city_landuse Frequency for du_est_city = 1",
x = "discrep_city_landuse",
y = "Frequency")
# Code 4.2b starts here
# Working discrep_addr_city, discrep_addr_landuse, discrep_city_landuse columns
# for Where du_est_city = 2
# discrep_addr_city column:
filtered_data_2 <- subset(disrep_data, du_est_city == 2 & discrep_addr_city != 0)
discrep_addr_city_counts_2 <- table(filtered_data_2$discrep_addr_city)
discrep_addr_city_counts_2_df <- as.data.frame(discrep_addr_city_counts_2)
colnames(discrep_addr_city_counts_2_df) <- c("discrep_addr_city", "Frequency")
ggplot(discrep_addr_city_counts_2_df, aes(x = discrep_addr_city, y = Frequency)) +
geom_bar(stat = "identity", fill = "red") +
labs(title = "Discrep_addr_city Frequency for du_est_city = 2",
x = "discrep_addr_city",
y = "Frequency")
# discrep_addr_landuse column:
filtered_data_2 <- subset(disrep_data, du_est_city == 2 & discrep_addr_landuse != 0)
discrep_addr_landuse_counts_2 <- table(filtered_data_2$discrep_addr_landuse)
discrep_addr_landuse_counts_2_df <- as.data.frame(discrep_addr_landuse_counts_2)
colnames(discrep_addr_landuse_counts_2_df) <- c("discrep_addr_landuse", "Frequency")
ggplot(discrep_addr_landuse_counts_2_df, aes(x = discrep_addr_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "red") +
labs(title = "Discrep_addr_landuse Frequency for du_est_city = 2",
x = "discrep_addr_landuse",
y = "Frequency")
# discrep_city_landuse column:
filtered_data_2 <- subset(disrep_data, du_est_city == 2 & discrep_city_landuse != 0)
discrep_city_landuse_counts_2 <- table(filtered_data_2$discrep_city_landuse)
discrep_city_landuse_counts_2_df <- as.data.frame(discrep_city_landuse_counts_2)
colnames(discrep_city_landuse_counts_2_df) <- c("discrep_city_landuse", "Frequency")
ggplot(discrep_city_landuse_counts_2_df, aes(x = discrep_city_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "red") +
labs(title = "Discrep_city_landuse Frequency for du_est_city = 2",
x = "discrep_city_landuse",
y = "Frequency")
# Code 4.2c starts here
# Working discrep_addr_city, discrep_addr_landuse, discrep_city_landuse columns
# for Where du_est_city = 3:
# discrep_addr_city column:
filtered_data_3 <- subset(disrep_data, du_est_city == 3 & discrep_addr_city != 0)
discrep_addr_city_counts_3 <- table(filtered_data_3$discrep_addr_city)
discrep_addr_city_counts_3_df <- as.data.frame(discrep_addr_city_counts_3)
colnames(discrep_addr_city_counts_3_df) <- c("discrep_addr_city", "Frequency")
ggplot(discrep_addr_city_counts_3_df, aes(x = discrep_addr_city, y = Frequency)) +
geom_bar(stat = "identity", fill = "green") +
labs(title = "Discrep_addr_city Frequency for du_est_city = 3",
x = "discrep_addr_city",
y = "Frequency")
# discrep_addr_landuse column:
filtered_data_3 <- subset(disrep_data, du_est_city == 3 & discrep_addr_landuse != 0)
discrep_addr_landuse_counts_3 <- table(filtered_data_3$discrep_addr_landuse)
discrep_addr_landuse_counts_3_df <- as.data.frame(discrep_addr_landuse_counts_3)
colnames(discrep_addr_landuse_counts_3_df) <- c("discrep_addr_landuse", "Frequency")
ggplot(discrep_addr_landuse_counts_3_df, aes(x = discrep_addr_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "green") +
labs(title = "Discrep_addr_landuse Frequency for du_est_city = 3",
x = "discrep_addr_landuse",
y = "Frequency")
# discrep_city_landuse column:
filtered_data_3 <- subset(disrep_data, du_est_city == 3 & discrep_city_landuse != 0)
discrep_city_landuse_counts_3 <- table(filtered_data_3$discrep_city_landuse)
discrep_city_landuse_counts_3_df <- as.data.frame(discrep_city_landuse_counts_3)
colnames(discrep_city_landuse_counts_3_df) <- c("discrep_city_landuse", "Frequency")
ggplot(discrep_city_landuse_counts_3_df, aes(x = discrep_city_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "green") +
labs(title = "Discrep_city_landuse Frequency for du_est_city = 3",
x = "discrep_city_landuse",
y = "Frequency")
# Code 4.2d starts here
# Working discrep_addr_city, discrep_addr_landuse, discrep_city_landuse columns
# for Where du_est_city = 4
# discrep_addr_city column:
filtered_data_4 <- subset(disrep_data, du_est_city == 4 & discrep_addr_city != 0)
discrep_addr_city_counts_4 <- table(filtered_data_4$discrep_addr_city)
discrep_addr_city_counts_4_df <- as.data.frame(discrep_addr_city_counts_4)
colnames(discrep_addr_city_counts_4_df) <- c("discrep_addr_city", "Frequency")
ggplot(discrep_addr_city_counts_4_df, aes(x = discrep_addr_city, y = Frequency)) +
geom_bar(stat = "identity", fill = "orange") +
labs(title = "Discrep_addr_city Frequency for du_est_city = 4",
x = "discrep_addr_city",
y = "Frequency")
# discrep_addr_landuse column:
filtered_data_4 <- subset(disrep_data, du_est_city == 4 & discrep_addr_landuse != 0)
discrep_addr_landuse_counts_4 <- table(filtered_data_4$discrep_addr_landuse)
discrep_addr_landuse_counts_4_df <- as.data.frame(discrep_addr_landuse_counts_4)
colnames(discrep_addr_landuse_counts_4_df) <- c("discrep_addr_landuse", "Frequency")
ggplot(discrep_addr_landuse_counts_4_df, aes(x = discrep_addr_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "orange") +
labs(title = "Discrep_addr_landuse Frequency for du_est_city = 4",
x = "discrep_addr_landuse",
y = "Frequency")
# discrep_city_landuse column:
filtered_data_4 <- subset(disrep_data, du_est_city == 4 & discrep_city_landuse != 0)
discrep_city_landuse_counts_4 <- table(filtered_data_4$discrep_city_landuse)
discrep_city_landuse_counts_4_df <- as.data.frame(discrep_city_landuse_counts_4)
colnames(discrep_city_landuse_counts_4_df) <- c("discrep_city_landuse", "Frequency")
ggplot(discrep_city_landuse_counts_4_df, aes(x = discrep_city_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "orange") +
labs(title = "Discrep_city_landuse Frequency for du_est_city = 4",
x = "discrep_city_landuse",
y = "Frequency")
# Code 4.2e starts here
# Working discrep_addr_city, discrep_addr_landuse, discrep_city_landuse columns
# for Where du_est_city = 5 to 20
# discrep_addr_city column:
filtered_data_5_to_20 <- subset(disrep_data, du_est_city >= 5 & du_est_city <= 20 & discrep_addr_city != 0)
discrep_addr_city_counts_5_to_20 <- table(filtered_data_5_to_20$discrep_addr_city)
discrep_addr_city_counts_5_to_20_df <- as.data.frame(discrep_addr_city_counts_5_to_20)
colnames(discrep_addr_city_counts_5_to_20_df) <- c("discrep_addr_city", "Frequency")
ggplot(discrep_addr_city_counts_5_to_20_df, aes(x = discrep_addr_city, y = Frequency)) +
geom_bar(stat = "identity", fill = "grey") +
labs(title = "Discrep_addr_city Frequency for du_est_city = 5 to 20",
x = "discrep_addr_city",
y = "Frequency")
# discrep_addr_landuse column:
filtered_data_5_to_20 <- subset(disrep_data, du_est_city >= 5 & du_est_city <= 20 & discrep_addr_landuse != 0)
discrep_addr_landuse_counts_5_to_20 <- table(filtered_data_5_to_20$discrep_addr_landuse)
discrep_addr_landuse_counts_5_to_20_df <- as.data.frame(discrep_addr_landuse_counts_5_to_20)
colnames(discrep_addr_landuse_counts_5_to_20_df) <- c("discrep_addr_landuse", "Frequency")
ggplot(discrep_addr_landuse_counts_5_to_20_df, aes(x = discrep_addr_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "grey") +
labs(title = "Discrep_addr_landuse Frequency for du_est_city = 5 to 20",
x = "discrep_addr_landuse",
y = "Frequency")
# discrep_city_landuse column:
filtered_data_5_to_20 <- subset(disrep_data, du_est_city >= 5 & du_est_city <= 20 & discrep_city_landuse != 0)
discrep_city_landuse_counts_5_to_20 <- table(filtered_data_5_to_20$discrep_city_landuse)
discrep_city_landuse_counts_5_to_20_df <- as.data.frame(discrep_city_landuse_counts_5_to_20)
colnames(discrep_city_landuse_counts_5_to_20_df) <- c("discrep_city_landuse", "Frequency")
ggplot(discrep_city_landuse_counts_5_to_20_df, aes(x = discrep_city_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "grey") +
labs(title = "Discrep_city_landuse Frequency for du_est_city = 5 to 20",
x = "discrep_city_landuse",
y = "Frequency")
# Code 4.2f starts here
# Working discrep_addr_city, discrep_addr_landuse, discrep_city_landuse columns
# for where du_est_city = more than 20
# discrep_addr_city column:
filtered_data_plus_20 <- subset(disrep_data, du_est_city >= 20 & discrep_addr_city != 0)
discrep_addr_city_counts_plus_20 <- table(filtered_data_plus_20$discrep_addr_city)
discrep_addr_city_counts_plus_20_df <- as.data.frame(discrep_addr_city_counts_plus_20)
colnames(discrep_addr_city_counts_plus_20_df) <- c("discrep_addr_city", "Frequency")
ggplot(discrep_addr_city_counts_plus_20_df, aes(x = discrep_addr_city, y = Frequency)) +
geom_bar(stat = "identity", fill = "brown") +
labs(title = "Discrep_addr_city Frequency for du_est_city >= 20",
x = "discrep_addr_city",
y = "Frequency")
# discrep_addr_landuse column:
filtered_data_plus_20 <- subset(disrep_data, du_est_city >= 20 & discrep_addr_landuse != 0)
discrep_addr_landuse_counts_plus_20 <- table(filtered_data_plus_20$discrep_addr_landuse)
discrep_addr_landuse_counts_plus_20_df <- as.data.frame(discrep_addr_landuse_counts_plus_20)
colnames(discrep_addr_landuse_counts_plus_20_df) <- c("discrep_addr_landuse", "Frequency")
ggplot(discrep_addr_landuse_counts_plus_20_df, aes(x = discrep_addr_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "brown") +
labs(title = "Discrep_addr_landuse Frequency for du_est_city >= 20",
x = "discrep_addr_landuse",
y = "Frequency")
# discrep_city_landuse column:
filtered_data_plus_20 <- subset(disrep_data, du_est_city >= 20 & discrep_city_landuse != 0)
discrep_city_landuse_counts_plus_20 <- table(filtered_data_plus_20$discrep_city_landuse)
discrep_city_landuse_counts_plus_20_df <- as.data.frame(discrep_city_landuse_counts_plus_20)
colnames(discrep_city_landuse_counts_plus_20_df) <- c("discrep_city_landuse", "Frequency")
ggplot(discrep_city_landuse_counts_plus_20_df, aes(x = discrep_city_landuse, y = Frequency)) +
geom_bar(stat = "identity", fill = "brown") +
labs(title = "Discrep_city_landuse Frequency for du_est_city >= 20",
x = "discrep_city_landuse",
y = "Frequency")