-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
269 lines (269 loc) · 11.5 KB
/
.Rhistory
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
votingdata$time = ifelse(votingdata$year >= 2013, 1, 0)
## white vs black voters
votingdata$treated = ifelse(votingdata$race == "black" , 1, 0)
votingdata = read.csv("/Users/hillaryrodriguez/Desktop/midterm elections.csv")
votingdata = read.csv("/Users/hillaryrodriguez/Desktop/presidential_elections.numbers")
## white vs black voters
votingdata$treated = ifelse(votingdata$race == "black" , 1, 0)
votingdata$did = votingdata$time * votingdata$treated
View(votingdata)
didreg1 = lm(y ~ treated*time, data = votingdata)
## white vs black registration
registration$treatedB = ifelse(registration$black == "black" , 1, 0)
## white vs black registration
registration$treatedB = ifelse(registration$black == "black" , 1, 0)
registration$didB = registration$time * registration$treated
registration$didB = registration$time * registration$treatedB
registration = read.csv("/Users/hillaryrodriguez/Desktop/presidential_elections.csv")
registration$y2 = H0 + H1*registration$time + H2*registration$treatedH + H3*registration$didH
H1 = 73.9 - H0
## white vs black registration
registration$treatedB = ifelse(registration$race == "black" , 1, 0)
registration = read.csv("/Users/hillaryrodriguez/Desktop/presidential_elections.numbers")
registration$time = ifelse(registration$year >= 2013, 1, 0)
## white vs black registration
registration$treatedB = ifelse(registration$race == "black" , 1, 0)
registration$didB = registration$time * registration$treatedB
B0 = 73.7
B1 = 73.9 - B0
B2 = 73.1 - B0
B3 = (69.4 - 73.1) - (73.9 - 73.7)
registration$y = B0 + B1*registration$time + B2*registration$treatedB + B3*registration$didB
didreg = lm(y ~ treatedB + time + didB, data = registration)
summary(didreg)
## white vs asian registration
registration$treatedA = ifelse(registration$race == "asian" , 1, 0)
registration$didA = registration$time * registration$treatedA
A0 = 73.7
A1 = 73.9 - A0
A2 = 73.1 - A0
A3 = (56.3 - 56.3) - (73.9 - 73.7)
registration$y1 = A0 + A1*registration$time + A2*registration$treatedA + A3*registration$didA
didreg1 = lm(y1 ~ treatedA + time + didA, data = registration)
summary(didreg1)
## white vs hispanic registration
registration$treatedH = ifelse(registration$race == "hispanic" , 1, 0)
registration$didH = registration$time * registration$treatedH
H0 = 73.7
H1 = 73.9 - H0
H2 = 58.7 - H0
H3 = (57.3 - 58.7) - (73.9 - 73.7)
registration$y2 = H0 + H1*registration$time + H2*registration$treatedH + H3*registration$didH
didreg2 = lm(y2 ~ treatedH + time + didH, data = registration)
summary(didreg2)
summary(didregH)
summary(didregH)
registrationH = read.csv("/Users/hillaryrodriguez/Desktop/presidential_elections_hispanic.numbers")
registrationH$timeH = ifelse(registrationH$year >= 2013, 1, 0)
library(foreign)
registrationB = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registration_black.numbers")
registrationB = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registratioon_black.numbers")
registrationB = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registration_black.numbers")
registrationH$timeH = ifelse(registrationH$year >= 2013, 1, 0)
registrationB$timeB = ifelse(registrationB$year >= 2013, 1, 0)
registrationB$timeB = ifelse(registrationB$year >= 2013, 1, 0)
View(registrationB)
registrationB = read.csv("/Users/hillaryrodriguez/Desktop/presidential_voting_black.numbers")
## white vs black registration
registrationB$treatedB = ifelse(registration$race == "black" , 1, 0)
View(registrationB)
registrationB = read.csv("/Users/hillaryrodriguez/Desktop/presidential_voting_black.numbers")
registrationB = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registration_black.csv")
View(registrationB)
registrationH = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registration_hispanic.csv")
registrationB$timeB = ifelse(registrationB$year >= 2013, 1, 0)
View(registrationB)
View(registrationH)
View(registrationH)
View(registrationB)
registrationB = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registration_black.csv")
View(registration)
View(registration)
View(registrationB)
View(registrationH)
registrationA = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registration_asian.csv")
View(registrationB)
View(registrationH)
View(registrationB)
View(registrationA)
registrationB$timeB = ifelse(registrationB$year >= 2013, 1, 0)
registrationA$timeA = ifelse(registrationA$year >= 2013, 1, 0)
registrationH$timeH = ifelse(registrationH$year >= 2013, 1, 0)
## white vs black registration
registrationB$treatedB = ifelse(registration$race == "black" , 1, 0)
registrationB$didB = registration$timeB * registration$treatedB
B0 = 73.7
B1 = 73.9 - B0
B2 = 73.1 - B0
B3 = (69.4 - 73.1) - (73.9 - 73.7)
## white vs asian registration
registrationA$treatedA = ifelse(registration$race == "asian" , 1, 0)
View(registrationA)
View(registrationB)
View(registrationH)
votingH$timeH = ifelse(votingH$year >= 2013, 1, 0)
votingB$timeB = ifelse(votingB$year >= 2013, 1, 0)
votingB = read.csv("/Users/hillaryrodriguez/Desktop/presidential_voting_black.csv")
votingA = read.csv("/Users/hillaryrodriguez/Desktop/presidential_voting_asian.csv")
votingH = read.csv("/Users/hillaryrodriguez/Desktop/presidential_voting_hispanic.csv")
votingB$timeB = ifelse(votingB$year >= 2013, 1, 0)
votingA$timeA = ifelse(votingA$year >= 2013, 1, 0)
votingH$timeH = ifelse(votingH$year >= 2013, 1, 0)
## white vs black voting
votingB$treatedB = ifelse(voting$race == "black" , 1, 0)
registrationB = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registration_black.csv")
registrationA = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registration_asian.csv")
registrationH = read.csv("/Users/hillaryrodriguez/Desktop/presidential_registration_hispanic.csv")
registrationB$timeB = ifelse(registrationB$year >= 2013, 1, 0)
registrationA$timeA = ifelse(registrationA$year >= 2013, 1, 0)
registrationH$timeH = ifelse(registrationH$year >= 2013, 1, 0)
## white vs black registration
registrationB$treatedB = ifelse(registrationB$race == "black" , 1, 0)
registrationB$didB = registration$timeB * registration$treatedB
registrationB$didB = registrationB$timeB * registrationB$treatedB
votingB$didB = votingB$timeB * votingB$treatedB
## white vs black voting
votingB$treatedB = ifelse(votingB$race == "black" , 1, 0)
votingB$didB = votingB$timeB * votingB$treatedB
B0 = 64.1
B1 = 65.3 - B0
B2 = 66.2 - B0
B3 = (59.4 - 66.2) - (65.3 - 64.1)
votingB$yB = B0 + B1*votingB$timeB + B2*votingB$treatedB + B3*votingB$didB
didregB = lm(yB ~ treatedB + timeB + didB, data = votingB)
summary(didregB)
registrationB$timeB = ifelse(registrationB$year >= 2013, 1, 0)
registrationA$timeA = ifelse(registrationA$year >= 2013, 1, 0)
registrationH$timeH = ifelse(registrationH$year >= 2013, 1, 0)
## white vs black registration
registrationB$treatedB = ifelse(registrationB$race == "black" , 1, 0)
registrationB$didB = registrationB$timeB * registrationB$treatedB
B0 = 73.7
B1 = 73.9 - B0
B2 = 73.1 - B0
B3 = (69.4 - 73.1) - (73.9 - 73.7)
registrationB$yB = B0 + B1*registrationB$timeB + B2*registrationB$treatedB + B3*registrationB$didB
didregB = lm(yB ~ treatedB + timeB + didB, data = registrationB)
summary(didregB)
shiny::runApp('Desktop/app')
runApp('Desktop/app')
install_github('CEHAT-Clinic/analysis')
devtools::document()
setwd('Desktop/analysis')
devtools::document()
runApp('~/Desktop/app')
runApp('~/Desktop/app')
Sys.getenv("GITHUB_PAT")
runApp('~/Desktop/app')
runApp('~/Desktop/app')
runApp('~/Desktop/app')
runApp('~/Desktop/app')
runApp('~/Desktop/app')
rsconnect::showLogs()
devtools::install_github("rstudio/shinytest", ref = "fc80bdbfe68bcd00329d61ef0cea8bc3cee00929")
(deployApp(upload=FALSE))
deployApp(upload=FALSE)
rsconnect::deployApp(upload = FALSE)
R_CONFIG_ACTIVE=shinyapps
Sys.getenv('GITHUB_PAT')
runApp('~/Desktop/app')
runApp('~/Desktop/app')
runApp('~/Desktop/app')
runApp('~/Desktop/app')
df <- data.frame()
epahist <- ggplot(df)
ggplotly(epahist)
epahist <- ggplot(df) + geom_point()
+ ggtitle("Days over EPA threshold in South Gate")
epahist <- ggplot(df)
+ ggtitle("Days over EPA threshold in South Gate")
epahist <- ggplot(df)+ ggtitle("Days over EPA threshold in South Gate")
ggplotly(epahist)
runApp('~/Desktop/app')
plot.new()
plot(main = "There is no mean percent difference for the old data")
df <- data.frame()
plot(df, main = "There is no mean percent difference for the old data")
runApp('~/Desktop/app')
PAhourly
PAhourly <- hourlyPA(newCleanPA(read.csv("pm25_april.csv")))
PAhourly <- hourlyPA(newCleanPA(read.csv("pm25_april.csv")),TRUE)
setwd('Desktop/app')
getwd()
setwd('..')
setwd('app')
PAhourly <- hourlyPA(newCleanPA(read.csv("pm25_april.csv")),TRUE)
avgSG <- PurpleAirCEHAT::summarySG(PAhourly)
PAhourly <- dplyr::left_join(PAhourly, avgSG, by = c("timestamp", "hour", "day"), keep=F)
if(input$answer == "Y" ){readings_underCT <- PurpleAirCEHAT::compareSensors(PAhourly,'b', TRUE)}
else if (input$answer == "N"){readings_underCT <- PurpleAirCEHAT::compareSensors(PAhourly,'b', FALSE)}
PAhourly <- dplyr::left_join(PAhourly, avgSG, by = c("timestamp", "hour", "day"), keep=F)
if("Y" == "Y" ){readings_underCT <- PurpleAirCEHAT::compareSensors(PAhourly,'b', TRUE)}
else if (input$answer == "N"){readings_underCT <- PurpleAirCEHAT::compareSensors(PAhourly,'b', FALSE)}
PAhourly <- dplyr::left_join(PAhourly, avgSG, by = c("timestamp", "hour", "day"), keep=F)
readings_underCT <- PurpleAirCEHAT::compareSensors(PAhourly,'b', TRUE)
sg.city <- PurpleAirCEHAT::southgate()
sg.city@data$id <- rownames(sg.city@data)
# create a data.frame from our spatial object
sg.cityPoints <- ggplot2::fortify(sg.city, region = "id")
# merge the "fortified" data with the data from our spatial object
sg.cityDF <- left_join(sg.cityPoints, sg.city@data, by = "id")
k <- ggplot(readings_underCT, aes(longitude, latitude)) +
geom_path(data = sg.city, aes(long, lat, group=id), color='black')+
geom_point(aes(size= count/total_readings, color=count/total_readings)) +
scale_color_gradient(low='violet', high='blue', name= "Normalized Low Values") +
xlim(-118.2325,-118.155) +
ylim(33.91029, 33.96837)+
guides(size=FALSE) +
ggtitle("Readings Under Median by Sensor")+
geom_text(aes(label=names), check_overlap = F, show.legend = F, size = 3, vjust = 2)+
theme_minimal()
ggplotly(k)
runApp()
runApp()
runApp()
knitr::opts_chunk$set(echo = TRUE)
library(shiny)
library(ggplot2)
library(plotly)
library(tidyverse)
library(zoo)
library(gridExtra)
library(PurpleAirCEHAT)
library(lubridate)
date1 <- params$d1
dates1 <- c(params$dts1)
dates2 <- c(params$dts2)
dates3 <- params$dts3
dates4 <- params$dts4
PAfull <- params$PAfull
PAhourly <- params$PAhourly
PAhi_lo <- params$highlow
downSensors <- params$down
avgSG <- params$summary
dailySG <- params$daily
sensor <- params$sensor
selectedSensors <- params$sensors
readings_underCT <- params$under
readings_overCT <- params$over
sg.city <- PurpleAirCEHAT::southgate()
#coverting the city into a data frame to work with ggplot
# add to data a new column termed "id" composed of the rownames of data
sg.city@data$id <- rownames(sg.city@data)
# create a data.frame from our spatial object
sg.cityPoints <- ggplot2::fortify(sg.city, region = "id")
# merge the "fortified" data with the data from our spatial object
sg.cityDF <- left_join(sg.cityPoints, sg.city@data, by = "id")
EPAcols <- c("Good"="#00e400", "Moderate"="#ffff00","Unhealthy for Sensitive Groups" = "#ff7e00", "Unhealthy" = "#ff0000", "Very Unhealthy" = "#8f3f97", "Hazardous" = "#7e0023")
wessy_pal <- c("high"="#C93312","low"="#899DA4")
Krigehourly <- PAhourly %>% dplyr::filter(PAhourly$timestamp == as_datetime(date1)+ lubridate::hours(params$hour))
runApp()
runApp()
getwd()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
runApp()