Skip to content

Commit 4d833b8

Browse files
author
Jenna Krall
committed
Added code for determining %BDL by source
1 parent c1cc556 commit 4d833b8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

nyc_data.R

+18-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ colnames(dat)[1:2] <- c("Date", "PM25")
9898

9999

100100

101+
102+
101103
write.csv(dat, file = "nycdat.csv", row.names = F)
102104

103105

@@ -171,7 +173,22 @@ write.csv(mdls, file = "mdls.csv", row.names = F)
171173

172174

173175

174-
176+
#####
177+
# get avg %mdl for each source
178+
bdls <- 1 * (sweep(dat[, -1], 2, mdlmax, "<"))
179+
pbdls <- round(apply(bdls, 2, mean), 2)
180+
181+
sour1 <- list()
182+
sour1[[1]] <- pbdls[c("aluminum", "calcium", "iron", "silicon", "titanium")]
183+
sour1[[2]] <- pbdls[c("sulfur", "ammonium_ion")]
184+
sour1[[3]] <- pbdls[c("OC", "elemental_carbon", "potassium")]
185+
sour1[[4]] <- pbdls[c("nickel", "vanadium", "nitrate",
186+
"chlorine", "lead", "zinc")]
187+
188+
meanmed <- function(x) {median(x, na.rm = T)}
189+
x <- sapply(sour1, meanmed)
190+
names(x) <- c("soil", "sec sulf", "traff", "resoil")
191+
x
175192

176193

177194

0 commit comments

Comments
 (0)