Skip to content

Instantly share code, notes, and snippets.

@alexstorer
Created April 8, 2013 21:17
Show Gist options
  • Save alexstorer/5340596 to your computer and use it in GitHub Desktop.
Save alexstorer/5340596 to your computer and use it in GitHub Desktop.
# Run the topics script first to load everything up.
npi[npidtm$fd>0,c('NPI_Description','aotitle',"plocstatename","ploccityname")]
outp <- textvec[grep('FD',textvec)]
grep('FIRE',outp)
outp[grep('FIRE',outp,invert=TRUE)]
npidtm$labelhospital <- 0
hospinds <- grep("HOSPITAL",textvec)
medcentinds <- grep("MEDICAL CENTER",textvec)
fireinds <- grep("FIRE",textvec)
labelhospinds <- setdiff(union(hospinds,medcentinds),fireinds)
npidtm$labelhospital[labelhospinds] <- 1
textvec[npidtm$labelhospital==1 & npidtm$fire>0]
# which are nonprofit?
table(npidtm$labelhospital==TRUE,npidtm$nonprofit)
# volunteer but not fire
volunteerinds <- which(npidtm$volunteer>0)
volinds <- which(npidtm$vol>0)
volnotfireinds <- setdiff(setdiff(union(volunteerinds,volinds),fireinds),labelhospinds)
identifiedinds <- union(fireinds,union(labelhospinds,volnotfireinds))
identifiedinds <- union(which(npidtm$owner>0),identifiedinds)
# label everything in npi_identified
npi_identified <- npi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment