15 LYBUNTs

# i always begin by loading the disco engine if it isn't already loaded
library(discoveryengine)

Anyone involved in an annual solicitation cycle will have some interest in the population referred to as LYBUNT, which stands for Last Year But Not This Year. That is, someone who gave last year but has not given this year. How can we create such a definition in the Disco Engine?

To make the example concrete, let’s say we’re identifying LYBUNTs for the school of Social Welfare. What I’d like to get to is:

LYBUNT = last_year %but_not% this_year

So, all I really need to do is define last_year and this_year. I’m writing this example in September, 2016, so I’ll define “last year” as FY2015-16, or in other words, July 1, 2015 - June 30, 2016:

last_year = gave_to_area(social_welfare, from = 20150701, to = 20160630)

And now for this year. Since the to argument is optional, I can just do:

this_year = gave_to_area(social_welfare, from = 20160701)

Now I can create my LYBUNT definition, as I strategized above:

LYBUNT = last_year %but_not% this_year
display(LYBUNT)
## # A tibble: 186 x 1
##    entity_id
##        <dbl>
##  1       448
##  2       548
##  3      3408
##  4     10025
##  5     14061
##  6     14063
##  7     18578
##  8     22160
##  9     25099
## 10     30764
## # … with 176 more rows

Finally, recall that every widget has a default set up if you don’t enter any codes. Looking at ?gave_to_area I can see that if I don’t use an area of giving codes, I just get any giving anywhere. I can use this knowledge to get campus-wide LYBUNTs:

last_year = gave_to_area(from = 20150701, to = 20160630)
this_year = gave_to_area(from = 20160701)
LYBUNT = last_year %but_not% this_year
display(LYBUNT)
## # A tibble: 22,029 x 1
##    entity_id
##        <dbl>
##  1         7
##  2        15
##  3       202
##  4       225
##  5       340
##  6       515
##  7       533
##  8       601
##  9       620
## 10       814
## # … with 22,019 more rows