Watts-College / cpp-527-fall-2021

A course shell for CPP 527 Foundations of Data Science II
https://watts-college.github.io/cpp-527-fall-2021/
2 stars 6 forks source link

Lab 4 Part III #36

Open lecy opened 2 years ago

lecy commented 2 years ago

Question from email:

I am stuck on part 3, question 1. I have selected words to identify organizations however, I am not able to see the results on my screen.

Here is what I have so far:

criteria.01 <- grep( "...", dat$mission, ignore.case = TRUE )
criteria.02 <- grepl( "...", dat$mission, ignore.case = TRUE )
criteria.03 <- grepl( "...", dat$mission, ignore.case = TRUE ) 
these.nonprofits <- ( criteria.01 | criteria.02 | criteria.03 )
sum( these.nonprofits )  # count of missions identified
lecy commented 2 years ago

Recall that these.nonprofits will be a logical vector or a "selector vector".

These are useful for counting things (sum), determining proportions (mean), and subsetting data:

np.black <- dat$mission[  these.nonprofits ]
np.black