More from this project:
Number of Registered 501(c)(3) Private Foundations by State
library(tidyverse)
library(httr)
library(stringr)
library(knitr)
library(reshape2)
library(extrafont)
source('https://raw.githubusercontent.com/UrbanInstitute/urban_R_theme/master/urban_theme_windows.R')
#Create a function to filter out unneccesary columns from the Business Master File
prepbmffile <- function(bmffilepath) {
output <- read_csv(bmffilepath,
col_types = cols_only(EIN = col_character(),
NTEECC = col_character(),
STATE = col_character(),
OUTNCCS = col_character(),
SUBSECCD = col_character(),
FNDNCD = col_character(),
CFILER = col_character(),
CZFILER = col_character(),
CTAXPER = col_character(),
CTOTREV = col_double(),
CASSETS = col_double()
))
names(output) <- toupper(names(output))
return(output)
}
#Run the function on the BMF
bmf2016 <- prepbmffile("Data/bm1608.csv")
#Filter the bmf to isolate nonprofits that are actively filing
output2<- bmf2016 %>%
#Filter out out of scope orgs
filter((OUTNCCS != "OUT")) %>%
filter((FNDNCD == "02" | FNDNCD == "03" | FNDNCD == "04")) %>%
#Filter out non 501(c)(3)s
filter(SUBSECCD =="03") %>%
#Filter out orgs that haven't filed taxes in the last 2 years
filter(CFILER == "Y") %>%
#filter(CZFILER == "N") %>%
#Total the filtered number of orgs and display by state
group_by(STATE)%>%
summarise(TotalActive = n())
#Filter the bmf to isolate number of nonprofits by state
output <- bmf2016 %>%
#filter out of scope orgs
filter((OUTNCCS != "OUT")) %>%
filter((FNDNCD == "02" | FNDNCD== "03" | FNDNCD == "04")) %>%
#Filter out non 501(c)(3)s
filter(SUBSECCD =="03") %>%
#Total the filtered number of orgs and display by state
group_by(STATE) %>%
summarize(TotalOrgs = n())
#join the two output files to a single table
final <- left_join(output, output2, by = "STATE")
#Add in full state names
final <- final %>%
mutate(State = state.name[match(STATE, state.abb)])
#DC isn't recognized as a state and displays as N/A. This function renames it.
final$State[final$STATE =="DC"] <- "Washington, DC"
#Rearrange the table and drop the state abbreviation column
final <- final %>%
select(State, TotalOrgs, TotalActive)
#Arrange states in alphabetical order
final <- final[order(final$State),]
#rename columns appropriately
colnames(final)<- c("State", "Number of Organizations", "Number Filing Annually")
#display table
kable(final, format.args = list(decimal.mark = '.', big.mark = ","))
State | Number of Organizations | Number Filing Annually |
---|---|---|
Alabama | 1,172 | 1,087 |
Alaska | 123 | 107 |
Arizona | 1,217 | 1,080 |
Arkansas | 493 | 431 |
California | 10,875 | 9,920 |
Colorado | 1,865 | 1,690 |
Connecticut | 1,853 | 1,749 |
Delaware | 1,494 | 1,433 |
Florida | 6,819 | 6,188 |
Georgia | 2,158 | 1,916 |
Hawaii | 487 | 450 |
Idaho | 364 | 327 |
Illinois | 5,934 | 5,616 |
Indiana | 1,431 | 1,316 |
Iowa | 1,076 | 1,018 |
Kansas | 912 | 851 |
Kentucky | 773 | 694 |
Louisiana | 832 | 715 |
Maine | 495 | 461 |
Maryland | 1,939 | 1,754 |
Massachusetts | 3,684 | 3,480 |
Michigan | 2,690 | 2,466 |
Minnesota | 1,603 | 1,500 |
Mississippi | 403 | 356 |
Missouri | 1,621 | 1,489 |
Montana | 351 | 328 |
Nebraska | 692 | 660 |
Nevada | 778 | 694 |
New Hampshire | 532 | 502 |
New Jersey | 3,555 | 3,285 |
New Mexico | 425 | 373 |
New York | 11,948 | 11,154 |
North Carolina | 4,285 | 4,098 |
North Dakota | 143 | 126 |
Ohio | 3,820 | 3,556 |
Oklahoma | 1,062 | 970 |
Oregon | 912 | 840 |
Pennsylvania | 5,471 | 5,196 |
Rhode Island | 1,769 | 1,744 |
South Carolina | 765 | 678 |
South Dakota | 207 | 186 |
Tennessee | 1,207 | 1,074 |
Texas | 6,466 | 5,894 |
Utah | 936 | 833 |
Vermont | 297 | 272 |
Virginia | 2,045 | 1,821 |
Washington | 1,712 | 1,540 |
Washington, DC | 531 | 484 |
West Virginia | 380 | 338 |
Wisconsin | 2,490 | 2,356 |
Wyoming | 313 | 286 |
Source: NCCS 501(c)(3) IRS Business Master File 2016