# IRS 1023 DATA
# Correct raw GitHub URL
# No longer functioning? URL <-"https://raw.githubusercontent.com/DS4PS/pe4ps-textbook/master/data/org-mission-statements.rds"
dat <- readRDS("/Users/Tyler/Desktop/thatsallfolks/TIY/website_v1/WebsiteAssets/Data/IRS-1023-EZ-MISSIONS.rds")

# Load the RDS directly (don't need now )
#dat <- readRDS(url(URL))

# Quick check
head(dat[c("orgname","codedef01","mission")])
##                             orgname                     codedef01
## 1              NIA PERFORMING ARTS  Arts, Culture, and Humanities
## 2       THE YOUNG ACTORS GUILD INC  Arts, Culture, and Humanities
## 3                   RUTH STAGE INC  Arts, Culture, and Humanities
## 4 STRIPLIGHT COMMUNITY THEATRE INC  Arts, Culture, and Humanities
## 5       NU BLACK ARTS WEST THEATRE  Arts, Culture, and Humanities
## 6     OLIVE BRANCH THEATRICALS INC  Arts, Culture, and Humanities
##                                                                                                                                                                                                                                        mission
## 1                                                                                                                                         A community based art organization that inspires, nutures,educates and empower artist and community.
## 2         We engage and educate children in the various aspect of theatrical productions, through acting, directing, and stage crew. We produce community theater productions for children as well as educational theater camps and workshops.
## 3                                                                                                                                                                                                     Theater performances and performing arts
## 4                                                                                                                                                                                                                                             
## 5                                                                                                                                                                                                                                             
## 6 To produce high-quality theater productions for our local community, guiding performers and audience members to a greater appreciation of creativity through the theatrical arts - while leading with respect, organization, accountability.

Part 1: Patterns

# Example Pattern
grep(pattern="some.reg.ex", x="mission statements", value=TRUE)

Missions with Numbers

grep(pattern="[0-9]", x=dat$mission, value=TRUE) %>% head() %>% pander()

Provide entertainment and education to private residence of a private residential community over 55., To serve the community as a nonprofit organization dedicated to producing live theatre and educational opportunities in the theater arts. The theater’s primary activity is to put on 3-5 plays annually in Colorado Springs, CO., The organization is a theater company that performs 3-4 plays per year., Our mission is to facilitate personal growth and social development through the creativity of the Theatre Arts. We offer musical theatre camps for ages 4-7, 8-12, and 13-20 in the summers & community theatre and classes for all ages fall-spring, Nurture minority actors, directors, playwrights, and theater artists by offering them the opportunity to participate in the best classic, contemporary, and original theater (A65 and R30). and The 574 Theatre Company strives to be a professional theatre company located in St. Joseph County, IN who seeks to create, inspire, and educate the members of the 574 community by producing high quality and innovative theatrical entertainment.

grepl("[0-9]", dat$mission) %>% sum()
## [1] 4142

1. Filter by: Starts with “to”

filter_to <- grep("^to", x=dat$mission, value=TRUE)
head(filter_to, 6) %>% pander()

to promote the great Agricultural Heritage through real life learning experiences that educate lead and inspire todays and future generations to come and espouse the legacy of the American farmers spirit, to educate the general public on the history of Sumner County and specifically the Bridal House historic home including presenting educational seminars, tours and other events open to the general public concerning historic events, to preserve, maintain and improve the historical structures and artifacts in and around the Township of Lebanon in the County of Hunterdon in the State of New Jersey, to inform the public of cultural events and exchanges between the City of Thibodaux and the City of Loudun to promote understanding of the culture and heritage of the City of Thibodaux, & operated as a non-profit, to dispense charitable and educational assistance and to perpetuate Scottish traditions and to provide a safe place for gay youth in castro valley, ca A event every July to promote gay prde

sum(grepl("^to", dat$mission))
## [1] 456

2. Filter by: blank mission statements

filter_blank <- grep("^[[:space:]]*$", x=dat$mission)
head(filter_blank, 6)
## [1]  4  5 18 29 36 44
sum(grepl("^[[:space:]]*$", dat$mission))
## [1] 4861

3. Filter by: Mission statements with trailing whitespace

filter_blank_end <- grepl("[[:space:]]+$", x=dat$mission)
sum(filter_blank_end)
## [1] 3464
trim_final_spaces <- function(x=dat$mission) sub("\\s+$", "", x)
trim_final_spaces() %>% head(6) %>% pander()

A community based art organization that inspires, nutures,educates and empower artist and community., We engage and educate children in the various aspect of theatrical productions, through acting, directing, and stage crew. We produce community theater productions for children as well as educational theater camps and workshops., Theater performances and performing arts, , and To produce high-quality theater productions for our local community, guiding performers and audience members to a greater appreciation of creativity through the theatrical arts - while leading with respect, organization, accountability.

4. Filter by: Missions with a dollar sign

filter_dollar <- grepl("\\$", x=dat$mission)
sum(filter_dollar)
## [1] 43