From e95e454215215e070f6ceb7441a29af3a8893fed Mon Sep 17 00:00:00 2001 From: Jae Yeon Kim Date: Wed, 4 Aug 2021 16:20:44 -0700 Subject: [PATCH 1/2] fix org_name_to_ein --- NAMESPACE | 1 + R/org_classify_description_texts.R | 48 ++++++++++++++++++++++++++++++ README.md | 1 - docs/pkgdown.yml | 4 +-- man/get_organization_ein.Rd | 19 ++++++++++++ 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 man/get_organization_ein.Rd 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..ae7d56e 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) diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 1b42931..2b44b4f 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,9 +1,9 @@ -pandoc: 2.11.4 +pandoc: '2.12' pkgdown: 1.6.1 pkgdown_sha: ~ articles: getting-IRS: getting-IRS.html getting-social-media-handles: getting-social-media-handles.html getting-websites: getting-websites.html -last_built: 2021-08-02T23:53Z +last_built: 2021-08-03T23:02Z diff --git a/man/get_organization_ein.Rd b/man/get_organization_ein.Rd new file mode 100644 index 0000000..b2e80b7 --- /dev/null +++ b/man/get_organization_ein.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/org_classify_description_texts.R +\name{get_organization_ein} +\alias{get_organization_ein} +\title{Search for the EIN an organization given a name and U.S. state} +\usage{ +get_organization_ein(state_abbrev, org_name) +} +\arguments{ +\item{state_abbrev}{A two-letter U.S. state abbreviation (e.g., CA)} + +\item{org_name}{The name of a nonprofit organization} +} +\value{ +If successful, the function returns the Employment Identification Number matching the organization name in the given state +} +\description{ +Search for the EIN an organization given a name and U.S. state +} From 4222bc381b306ffb19144f175c045813d96d0fd3 Mon Sep 17 00:00:00 2001 From: Jae Yeon Kim Date: Wed, 1 Sep 2021 10:58:51 -0700 Subject: [PATCH 2/2] correct typos --- README.md | 2 +- docs/articles/getting-IRS.html | 2 +- .../header-attrs-2.10/header-attrs.js | 12 ++ .../getting-social-media-handles.html | 2 +- .../header-attrs-2.10/header-attrs.js | 12 ++ docs/articles/getting-websites.html | 2 +- .../header-attrs-2.10/header-attrs.js | 12 ++ docs/index.html | 3 +- docs/pkgdown.yml | 4 +- docs/reference/get_organization_ein.html | 187 ++++++++++++++++++ docs/reference/index.html | 6 + 11 files changed, 236 insertions(+), 8 deletions(-) create mode 100644 docs/articles/getting-IRS_files/header-attrs-2.10/header-attrs.js create mode 100644 docs/articles/getting-social-media-handles_files/header-attrs-2.10/header-attrs.js create mode 100644 docs/articles/getting-websites_files/header-attrs-2.10/header-attrs.js create mode 100644 docs/reference/get_organization_ein.html diff --git a/README.md b/README.md index ae7d56e..8388d35 100644 --- a/README.md +++ b/README.md @@ -171,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 @@ -
+