diff --git a/NAMESPACE b/NAMESPACE index 03ea44a..2b0fba7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -29,6 +29,7 @@ export(get_financial_details_990) export(get_financial_details_990ez) export(get_foundation_ein) export(get_grantmaking_details_990) +export(get_organization_ein) export(get_organization_name_990) export(get_scheduleO) export(get_scheduleR) diff --git a/R/org_classify_description_texts.R b/R/org_classify_description_texts.R index 324f93b..07ed3e6 100644 --- a/R/org_classify_description_texts.R +++ b/R/org_classify_description_texts.R @@ -262,6 +262,54 @@ get_organization_name_990 <- function(ein) { return(organization_name) } +#' Search for the EIN an organization given a name and U.S. state +#' +#' @param state_abbrev A two-letter U.S. state abbreviation (e.g., CA). This input should be character. +#' @param org_name The name of a nonprofit organization. This input should be character. +#' +#' @return If successful, the function returns the Employment Identification Number matching the organization name in the given state +#' @importFrom dplyr filter +#' @importFrom dplyr select +#' @importFrom dplyr arrange +#' @export + +org_name_to_ein <- function(state_abbrev, org_name) { + + if (!is.character(state_abbrev)) { + + stop("Error: state_abbrev should be character.") + + } + + if (!is.character(org_name)) { + + stop("Error: org_name should be characer.") + + } + + # require exact match for short names + if (nchar(org_name) < 5) { + arrange(desc(REVENUE_AMT)) + + # allow fuzzy match for longer names + } else { + + possible_matches <- eo1 %>% + filter(STATE == state_abbrev) %>% + filter(agrepl(toupper(org_name), NAME, max.distance = 0.01)) %>% + select(NAME, STREET, CITY, STATE, REVENUE_AMT,INCOME_AMT,ASSET_AMT,EIN) %>% + arrange(desc(REVENUE_AMT)) + + } + + if (nrow(possible_matches) == 0) { + ein <- NA + } else { + ein <- possible_matches$EIN[1] + } + + return(ein) +} #' Get Employer Identification Numbers (EINs) associated with foundations #' diff --git a/README.md b/README.md index 3668975..8388d35 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ # MapAgora -[![R-CMD-check](https://github.com/snfagora/MapAgora/workflows/R-CMD-check/badge.svg)](https://github.com/snfagora/MapAgora/actions) [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) @@ -172,4 +171,4 @@ To cite **MapAgora**, use: ## Acknowledgements -We acknowledge support from the SNF Agora Institue and P3 Lab at the Johns Hopkins University. +We acknowledge the administrative and financial support from the SNF Agora Institute and P3 Lab at Johns Hopkins University. diff --git a/docs/articles/getting-IRS.html b/docs/articles/getting-IRS.html index 24cb73e..046b0a7 100644 --- a/docs/articles/getting-IRS.html +++ b/docs/articles/getting-IRS.html @@ -85,7 +85,7 @@ -
+