Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
nt_conc formula
Browse files Browse the repository at this point in the history
  • Loading branch information
timathomas committed Oct 2, 2020
1 parent 240b726 commit 48b1253
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions R/nt.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@
# categories).
# ==========================================================================

nt <- function(df, GEOID = "GEOID", totraceE = "toteraceE", pWhite = "pWhite", pBlack = "pBlack", pAsian = "pAsian", pLatinx = "pLatinx", pOther = "pOther"){
nt <- function(
df,
GEOID = "GEOID",
totraceE = "toteraceE",
pWhite = "pWhite",
pBlack = "pBlack",
pAsian = "pAsian",
pLatinx = "pLatinx",
pOther = "pOther",
NeighType = "NeighType",
nt_conc = "nt_conc"
){

df %>%
dplyr::group_by(GEOID) %>%
Expand Down Expand Up @@ -76,6 +87,36 @@ nt <- function(df, GEOID = "GEOID", totraceE = "toteraceE", pWhite = "pWhite", p
pWhite >=.1 & pBlack >=.1 & pAsian >=.1 & pLatinx >=.1 & pOther < .1 ~ "White-Black-Asian-Latinx",

pWhite >.1 & pWhite <=.7 & pBlack >.1 & pAsian >.1 & pLatinx >.1 & pOther >.1 ~ "Diverse",
totraceE == 0 ~ "unpopulated tract")) %>%
dplyr::ungroup()
totraceE == 0 ~ "Unpopulated Tract")) %>%
dplyr::ungroup() %>%
dplyr::mutate(nt_conc =
dplyr::case_when(
NeighType == "Black-Asian-Latinx-Other" ~ "4 Group Mixed",
NeighType == "White-Asian-Latinx-Other" ~ "4 Group Mixed",
NeighType == "White-Black-Latinx-Other" ~ "4 Group Mixed",
NeighType == "White-Black-Asian-Other" ~ "4 Group Mixed",
NeighType == "White-Black-Asian-Latinx" ~ "4 Group Mixed",
NeighType == "Black-Asian-Latinx" ~ "3 Group Mixed",
NeighType == "Black-Asian-Other" ~ "3 Group Mixed",
NeighType == "Black-Latinx-Other" ~ "3 Group Mixed",
NeighType == "Asian-Latinx-Other" ~ "3 Group Mixed",
NeighType == "White-Black-Asian" ~ "3 Group Mixed",
NeighType == "White-Black-Latinx" ~ "3 Group Mixed",
NeighType == "White-Black-Other" ~ "3 Group Mixed",
NeighType == "White-Asian-Latinx" ~ "3 Group Mixed",
NeighType == "White-Asian-Other" ~ "3 Group Mixed",
NeighType == "White-Latinx-Other" ~ "3 Group Mixed",
NeighType == "White-Latinx-Other" ~ "3 Group Mixed",
NeighType == "All White" ~ "Mostly White",
NeighType == "All Black" ~ "Mostly Black",
NeighType == "All Asian" ~ "Mostly Asian",
NeighType == "All Latinx" ~ "Mostly Latinx",
NeighType == "All Other" ~ "Mostly Other",
NeighType == "White-Shared" ~ "Mostly White",
NeighType == "Black-Shared" ~ "Mostly Black",
NeighType == "Asian-Shared" ~ "Mostly Asian",
NeighType == "Latinx-Shared" ~ "Mostly Latinx",
NeighType == "Other-Shared" ~ "Mostly Other"
)
)
}

0 comments on commit 48b1253

Please sign in to comment.