Loading, setting up

library(tidyverse) # analysis and processing
library(DBI) # database interface
library(scales) # plots
library(quanteda) # text analysis

cn <- dbConnect(RSQLite::SQLite(), dbname = here::here("db", "k12-institutions-fb-posts.sqlite"))
ss_collected <- tbl(cn, "posts") %>% 
  filter(year == 2020) %>% 
  collect()
ss_collected
## # A tibble: 3,052,643 x 37
##    page_name user_name facebook_id likes_at_posting created type  likes comments
##    <chr>     <chr>           <dbl>            <int>   <dbl> <chr> <dbl>    <dbl>
##  1 Mountain… mountain…     1.55e14             2282  1.60e9 Link      1        0
##  2 Okaloosa… Okaloosa…     1.73e14            16602  1.60e9 Photo     2        0
##  3 Paul R. … PaulRBro…     2.13e14               NA  1.60e9 Photo    11        0
##  4 Western … WesternC…     1.56e11               NA  1.60e9 Photo    76        6
##  5 English … Englishv…     1.44e15              876  1.60e9 Link      0        0
##  6 Dierks H… DierksOu…     4.82e14               NA  1.60e9 Photo    25        0
##  7 Bartow C… <NA>          4.39e11            16879  1.60e9 Link     16        2
##  8 Muskogee… Muskogee…     4.96e10             6344  1.60e9 Photo   140       19
##  9 Mountain… mountain…     1.55e14             2282  1.60e9 Photo    11        0
## 10 Tompkins… tsmsonli…     3.22e14               NA  1.60e9 Photo     0        0
## # … with 3,052,633 more rows, and 29 more variables: shares <dbl>, love <dbl>,
## #   wow <dbl>, haha <dbl>, sad <dbl>, angry <dbl>, care <dbl>,
## #   video_share_status <chr>, post_views <dbl>, total_views <dbl>,
## #   total_views_for_all_crossposts <dbl>, video_length <chr>, url <chr>,
## #   message <chr>, link <chr>, final_link <chr>, image_text <chr>,
## #   link_text <chr>, description <chr>, sponsor_id <chr>, sponsor_name <chr>,
## #   overperforming_score <dbl>, hour <int>, day <dbl>, year <dbl>, month <dbl>,
## #   day_of_week <dbl>, day_of_month <int>, created_rounded_to_day <dbl>

Text

my_corpus <- corpus(ss_collected, text_field = "message")

my_tokens <- tokens(my_corpus, remove_symbols = T, remove_numbers = T, remove_punct = T, remove_url = T)

my_dfm <- quanteda::dfm(my_tokens, remove = stopwords('en'))

Frequencies

Overall

textstat_frequency(my_dfm, n = 10, groups = "month")
##        feature frequency rank docfreq group
## 1       school    149568    1   94179     1
## 2     students    109230    2   73992     1
## 3      january     63500    3   50170     1
## 4         high     47742    4   35194     1
## 5          day     39928    5   31695     1
## 6       please     35333    6   29593     1
## 7        today     34809    7   32231     1
## 8         year     32557    8   26056     1
## 9          new     30328    9   24653     1
## 10  basketball     30249   10   23078     1
## 11      school    121725    1   77281     2
## 12    students     92693    2   62703     2
## 13    february     46227    3   37140     2
## 14         day     42859    4   33525     2
## 15        high     40841    5   30432     2
## 16       today     32005    6   29655     2
## 17        week     29075    7   23072     2
## 18      please     26651    8   22420     2
## 19        team     26019    9   18622     2
## 20       grade     24198   10   18306     2
## 21      school    200826    1  105096     3
## 22    students    157069    2   92712     3
## 23       march    100828    3   65255     3
## 24      please     95690    4   69267     3
## 25         can     59730    5   43696     3
## 26 information     56097    6   41682     3
## 27        time     55973    7   41099     3
## 28          de     55772    8    8434     3
## 29     schools     53588    9   36092     3
## 30    families     53367   10   38045     3
## 31      school    148620    1   84403     4
## 32    students    108349    2   69259     4
## 33      please     69050    3   51396     4
## 34       april     57574    4   41228     4
## 35         can     54085    5   40701     4
## 36         day     53120    6   41426     4
## 37    learning     48618    7   31890     4
## 38        week     46363    8   35256     4
## 39        time     42452    9   32862     4
## 40          us     42051   10   34180     4
## 41      school    163099    1   95622     5
## 42    students     96379    2   64098     5
## 43         may     78433    3   52914     5
## 44      please     60296    4   45825     5
## 45         day     59639    5   47287     5
## 46       class     54811    6   45053     5
## 47        high     54272    7   40502     5
## 48       thank     50979    8   44179     5
## 49        week     50621    9   39338     5
## 50        year     50102   10   36563     5
## 51      school    108386    1   60156     6
## 52    students     52003    2   32359     6
## 53        june     42705    3   29954     6
## 54      please     39623    4   31130     6
## 55        year     31849    5   23842     6
## 56        high     30181    6   22256     6
## 57      summer     29429    7   21361     6
## 58       class     25493    8   21196     6
## 59          de     24555    9    4602     6
## 60         can     23835   10   18850     6
## 61      school    114236    1   55727     7
## 62    students     51669    2   26908     7
## 63      please     43653    3   33210     7
## 64        july     38788    4   27747     7
## 65        year     31475    5   23037     7
## 66    learning     25940    6   13706     7
## 67 information     24841    7   19369     7
## 68          de     24436    8    4229     7
## 69         can     23948    9   18454     7
## 70    families     21623   10   15301     7
## 71      school    156879    1   83874     8
## 72    students     93231    2   50934     8
## 73      please     63634    3   47118     8
## 74      august     46586    4   32853     8
## 75        year     44644    5   33375     8
## 76         day     37618    6   27568     8
## 77    learning     36067    7   23004     8
## 78          de     34559    8    6609     8
## 79         can     34317    9   26513     8
## 80 information     33258   10   26042     8
## 81      school    127843    1   72743     9
## 82    students     96937    2   57256     9
## 83      please     51966    3   39899     9
## 84         day     45428    4   33598     9
## 85   september     44324    5   33927     9
## 86          de     33785    6    6957     9
## 87         can     33570    7   26309     9
## 88        week     30901    8   23888     9
## 89    learning     30658    9   21349     9
## 90        high     29324   10   21674     9

By month - weighted

my_dfm %>% 
  dfm_tfidf() %>% 
  textstat_frequency(n = 10, groups = "month", force = TRUE) %>% 
  as_tibble() %>% 
  select(feature, rank, group) %>% 
  group_split("group")
## <list_of<
##   tbl_df<
##     feature: character
##     rank   : integer
##     group  : character
##     "group": character
##   >
## >[1]>
## [[1]]
## # A tibble: 90 x 4
##    feature     rank group `"group"`
##    <chr>      <int> <chr> <chr>    
##  1 january        1 1     group    
##  2 school         2 1     group    
##  3 students       3 1     group    
##  4 basketball     4 1     group    
##  5 high           5 1     group    
##  6 boys           6 1     group    
##  7 girls          7 1     group    
##  8 day            8 1     group    
##  9 grade          9 1     group    
## 10 jan           10 1     group    
## # … with 80 more rows

By month - not weighted

my_dfm %>% 
  textstat_frequency(n = 10, groups = "month", force = TRUE) %>% 
  as_tibble() %>% 
  select(feature, rank, group) %>% 
  group_split("group")
## <list_of<
##   tbl_df<
##     feature: character
##     rank   : integer
##     group  : character
##     "group": character
##   >
## >[1]>
## [[1]]
## # A tibble: 90 x 4
##    feature     rank group `"group"`
##    <chr>      <int> <chr> <chr>    
##  1 school         1 1     group    
##  2 students       2 1     group    
##  3 january        3 1     group    
##  4 high           4 1     group    
##  5 day            5 1     group    
##  6 please         6 1     group    
##  7 today          7 1     group    
##  8 year           8 1     group    
##  9 new            9 1     group    
## 10 basketball    10 1     group    
## # … with 80 more rows

Key words in context

From report

kwic(my_tokens, "learning") %>% slice(1:10)
##                                                                            
##     [text1, 5]                           The Parent Letter and | Learning |
##   [text11, 42]                    snapshot of our daily remote | learning |
##   [text16, 34]                    year on August with Distance | Learning |
##  [text16, 116]                   a different and more complete | learning |
##  [text16, 151]            families We are relaunching Distance | Learning |
##  [text16, 195]               new state requirements for online | learning |
##  [text16, 205]                         be made to our Distance | Learning |
##  [text16, 225]   classmates and participate in socio-emotional | learning |
##  [text16, 228] in socio-emotional learning-Teacher facilitated | learning |
##  [text16, 233]      learning including live instruction guided | learning |
##                                              
##  Options Survey is now available             
##  schedule#TigerPride                         
##  due to the mandates provided                
##  experience for our students I               
##  with significant changes and upgrades       
##  the following changes will be               
##  program-Daily opportunities for students    
##  -Teacher facilitated learning including live
##  including live instruction guided learning  
##  and small group instruction throughout
kwic(my_tokens, "technology") %>% slice(1:10)
##                                                                      
##    [text352, 2]                                                 Our |
##   [text402, 17]                              will need to check out |
##    [text414, 4]                         STUDENT INFORMATION LUNCHES |
##   [text414, 20]                  this year's student lunch schedule |
##   [text448, 51]                       Middle School student to have |
##  [text639, 202]                    these tools please reference the |
##  [text665, 471]             Classroom 5-12 incorporating new Google |
##    [text793, 2]                                              TUSD's |
##  [text815, 164]                       means of securing funding for |
##  [text1059, 73] additional professional development associated with |
##                                                                   
##  technology | team is the BEST in                                 
##  technology | from the school                                     
##  TECHNOLOGY | ETC Click link to access                            
##  technology | and more                                            
##  technology | it will deliver a new                               
##  Technology | Resources page on the MPHS                          
##  technology | Provide visibility to teacher summer                
##  Technology | Department making preparations for the              
##  technology | professional development intervention programming On
##  technology | integration The change in the
kwic(my_tokens, "student") %>% slice(1:10)
##                                                               
##  [text16, 295]     -New web-based tools to support | student |
##  [text16, 417]       along with information on our | student |
##   [text37, 69]              the s off your child's | student |
##   [text37, 91]         password So if your child's | student |
##   [text46, 11]               Comes the Bus if your | student |
##   [text51, 29]    access Class Choice through your | student |
##    [text57, 6] A message regarding powerschool and | student |
##   [text57, 28]  virtual platform The finalizing of | student |
##   [text58, 16]                  the life of a YISD | student |
##  [text77, 327]     been fully developed-During the | Student |
##                                               
##  learning including adaptive standards aligned
##  breakfast and lunch program We               
##  number and put a lowercase                   
##  number was s1234567 you would                
##  rides the bus and you                        
##  PowerSchool account and click on             
##  schedules Because of COVID-19 some           
##  schedules had to be put                      
##  during online learning If you                
##  and Family Orientation Days August
kwic(my_tokens, "education") %>% slice(1:10)
##                                                                          
##     [text3, 35]                  Carolina She was a special | education |
##    [text15, 74]              support our students and their | education |
##   [text16, 280]       achieve grade level standards-Special | Education |
##   [text77, 287]      that incorporates an in-person outdoor | education |
##    [text87, 35]               School District and San Diego | Education |
##   [text87, 157] mathematics science social studies physical | education |
##   [text118, 22]                       of the LBUSD Board of | Education |
##   [text193, 34]                   coach and teacher He left | education |
##  [text203, 278]                   be provided with the best | education |
##   [text235, 13]             and the Minnesota Department of | Education |
##                                              
##  teacher in Lenoir county and                
##  #HCSDStrong                                 
##  and related services and support            
##  component The district will roll            
##  Association announced an agreement yesterday
##  and the arts Students will                  
##  the information presented at the            
##  to serve as a firefighter                   
##  that they deserve We are                    
##  have released information as it
kwic(my_tokens, "teaching") %>% slice(1:10)
##                                                           
##    [text3, 27]     spent the last three years | teaching |
##   [text24, 12]   Year Round Schools have been | teaching |
##  [text164, 15] questions about the restart of | teaching |
##  [text271, 17]       the newest member of our | teaching |
##  [text505, 85] teachers represent the best of | teaching |
##  [text637, 18]    Family Coach Fuller will be | teaching |
##  [text662, 18]  Jaguar Family Jessica will be | teaching |
##  [text662, 39]   High School and received her | teaching |
##  [text691, 49]         are so glad she picked | teaching |
##   [text716, 9]           link to view the AEA | Teaching |
##                                 
##  in North Carolina She was      
##  remotely and what to expect    
##  and learning in the fall       
##  team We are glad to            
##  in the SRVUSD and we           
##  P.E this year and has          
##  First Grade Language Arts and  
##  degree from Texas State Jessica
##                                 
##  and Learning Plan for 2020-2021
kwic(my_tokens, "online") %>% slice(1:10)
##                                                                     
##  [text16, 194]             and new state requirements for | online |
##   [text23, 43]                    sold August 7th and 8th | online |
##   [text51, 81]           with teachers at Timpview Option | Online |
##   [text51, 89]               with eSchool We are offering | online |
##  [text51, 101]               your schedule You can choose | online |
##  [text51, 134]                       days or Odd days All | online |
##   [text58, 18]                   of a YISD student during | online |
##   [text58, 35]              to face learning or continued | online |
##   [text81, 32]              platform for the fall whether | online |
##   [text87, 42] announced an agreement yesterday regarding | online |
##                                     
##  learning the following changes will
##  at bidcal.com If you haven't       
##  at home with eSchool We            
##  eSchool classes in every period    
##  classes by taking them The         
##  All students will engage in        
##  learning If you haven't let        
##  learning after the mandatory three 
##  or face to face GO                 
##  learning for the 2020-2021 school
kwic(my_tokens, "teacher") %>% slice(1:10)
##                                                                   
##    [text3, 36]             She was a special education | teacher |
##     [text8, 6] Matthew Catlett Muskogee Public Schools | Teacher |
##  [text16, 218]   relationships and interact with their | teacher |
##   [text50, 17]               Warren ISD family The new | teacher |
##  [text51, 147]      Advisory class with their assigned | teacher |
##  [text51, 155]         from 00am-9 45am Their assigned | teacher |
##    [text85, 8]            posting 7-12 grade PE Health | Teacher |
##    [text98, 4]                        Virtual Meet The | Teacher |
##   [text101, 4]                        Virtual Meet The | Teacher |
##  [text166, 68]             may also email your child's | teacher |
##                                            
##  in Lenoir county and recently             
##  of the year is all                        
##  and classmates and participate in         
##  luncheon with principals and mentors      
##  every Friday from 00am-9 45am             
##  information is forthcoming via PowerSchool
##  North Miami Community Schools has         
##  Slide Show and Videos K-5                 
##  Slide Show and Videos MS                  
##  and they will forward your

Other terms

kwic(my_tokens, "covid") %>% slice(1:10)
##                                                                    
##   [text77, 169]           and or regulations the terrible | COVID |
##  [text317, 364]         as possible during the continuing | COVID |
##   [text499, 51]               4th All practices will have | COVID |
##   [text509, 63]                    Roma High Class of ICU | COVID |
##   [text782, 20]              school year Head to scoe.org | covid |
##   [text929, 28]               Based on State and National | COVID |
##   [text957, 20]              school year Head to scoe.org | covid |
##   [text1203, 3]                                    Due to | COVID |
##  [text1209, 59]               has worked closely with our | COVID |
##  [text1292, 15] Instructional Operational Plan During the | COVID |
##                                     
##  numbers for Grant County I         
##  crisis                             
##  screenings and temp checks prior   
##  Unit Internal Medicine Physician at
##  to access all of SCOE's            
##  trends it is anticipated that      
##  to access all of SCOE's            
##  circumstances the Prom was canceled
##  liaison in order to establish      
##  Pandemic Plan For a Strong
kwic(my_tokens, "school") %>% slice(1:10)
##                                                                   
##    [text3, 52]                    to pursue a degree in | school |
##   [text10, 21]               about how to safely reopen | school |
##    [text11, 9]                     for our first day of | school |
##   [text15, 13]                  today a big donation of | school |
##   [text16, 28]                 we would be starting our | school |
##   [text16, 67]               the state has not provided | school |
##  [text16, 241] group instruction throughout the regular | school |
##  [text16, 351]     elementary and secondary middle high | school |
##  [text16, 394]               to you from your student's | school |
##    [text29, 5]        Congratulations Eden Prairie High | School |
##                                      
##  psychology Welcome aboard ma'am     
##  this Fall Parents can share         
##  on August For the safety            
##  supplies from the United Way        
##  year on August with Distance        
##  districts with the criteria form    
##  day-High quality subject specific   
##  students NOTE The links were        
##  Information on loan of laptops      
##  #CLASSOF2020 Check out our Instagram
kwic(my_tokens, "website") %>% slice(1:10) 
##                                                            
##     [text1, 14]   now available on the district | website |
##     [text34, 8]           created a page on our | website |
##    [text85, 18]    has open positions Visit our | website |
##    [text89, 27]          at pm Please visit our | website |
##   [text109, 12]    live on the Martinsville ISD | website |
##   [text118, 41]     are available online on our | website |
##  [text162, 180]       be viewed on our district | website |
##    [text200, 6] Information is available on our | website |
##  [text203, 321]           year If not visit our | website |
##   [text207, 36]         this link or our school | website |
##                                             
##                                             
##  with Hurricane Isaias information including
##  employment section to see a                
##  to view the Zoom meeting                   
##  Please follow the link here                
##                                             
##  An important reminder that due             
##  regarding what you can expect              
##  coastal prep.cfacademy.school and Apply Now
##  to view the broadcast on
kwic(my_tokens, "resource") %>% slice(1:10)
##                                                                         
##   [text575, 58]                       The LCSS website is a | resource |
##  [text582, 611]             Please note students who attend | Resource |
##  [text718, 139]                     School Safety Plan as a | resource |
##   [text1252, 5]                             Here is a great | resource |
##   [text1618, 5]                        Check out this great | resource |
##  [text1948, 20] website's homepage and Coronavirus Response | resource |
##  [text1953, 25]               now available in the COVID-19 | resource |
##   [text2256, 5]                             Here is a great | resource |
##  [text2256, 23]                   Pediatrics This is a good | resource |
##   [text2288, 4]                           The Alisal Family | Resource |
##                                   
##  for parents guardians staff and  
##  Classrooms have supply lists that
##  when it is released or           
##  one of our parents shared        
##  for families and members of      
##  page                             
##  section of the District website  
##  from passed on by our            
##  for parents in relation to       
##  Center Newsletter has a plethora
kwic(my_tokens, "link") %>% slice(1:10)
##                                                          
##     [text7, 7] GRADUATION Here's the live stream | link |
##    [text37, 4]                  Please click the | link |
##    [text63, 6]            AISD parents here is a | link |
##   [text64, 30]           You will be receiving a | link |
##   [text73, 11]            AISD parents here is a | link |
##   [text81, 11]      families please click on the | link |
##  [text109, 16]     ISD website Please follow the | link |
##  [text186, 38]                at 8PM or use this | link |
##  [text190, 23]               QR Code or use this | link |
##  [text195, 38]                at 8PM or use this | link |
##                                    
##  if you cannot be there            
##  below to view a video             
##  to our Reopening Plan and         
##  to the meetings at pm             
##  to our Reopening Plan and         
##  to reach communications about next
##  here to view them Also            
##  #Classof2020YouDidIt              
##                                    
##  #Classof2020YouDidIt
kwic(my_tokens, "laptop") %>% slice(1:10)
##                                                                  
##   [text203, 163]        the teacher's proximity to the | laptop |
##    [text956, 10]               to pick up your student | laptop |
##    [text956, 28]                  work and to get your | laptop |
##   [text1006, 11] providing school supplies including a | laptop |
##   [text1485, 50]              does not have a district | laptop |
##   [text1531, 48]                 gr 2-5 will receive a | laptop |
##    [text1648, 9]             you who cannot access the | laptop |
##   [text1872, 40]          including but not limited to | laptop |
##  [text1872, 157]          including but not limited to | Laptop |
##  [text2085, 126]              don't already have one a | laptop |
##                                            
##  and other background noise-External       
##  Available until pm tonight-7              
##  or call 615-810-8370 to schedule          
##  to all of our students                    
##  or access to the internet                 
##  Please bring your student ID              
##  troubleshooting document from our previous
##  computers tablets and internet access     
##  Desktop computer tablet Wifi Hotspot       
##  sleeve or case that fits
kwic(my_tokens, "internet") %>% slice(1:10) 
##                                                                      
##   [text16, 401]                   on loan of laptops and | Internet |
##   [text308, 44]         option IMPORTANTE Las clases por | internet |
##   [text308, 76]                  Clases en persona y por | internet |
##  [text423, 122]     learning programs and providing free | Internet |
##   [text448, 66]               learning and access to the | internet |
##   [text561, 10] Sparklight has extended their discounted | internet |
##   [text561, 22]      make available its Mbps residential | internet |
##    [text698, 6]               Alabama to give million in | internet |
##   [text805, 54]            or remote instruction via the | internet |
##  [text805, 103]            or remote instruction via the | internet |
##                                         
##  hot spots will also be                 
##  comienzan para todos los alumnos       
##  disponibles para el ciclo escolar      
##  access to serving millions of          
##  This initiative will directly correlate
##  package The company will continue      
##  plan for per month for                 
##  vouchers for low-income students       
##  with daily live and recorded           
##  with daily live and recorded
kwic(my_tokens, "access") %>% slice(1:10)
##                                                                          
##    [text51, 24]                        needed You will need to | access |
##    [text53, 41]                   School Video for students to | access |
##  [text203, 110]                            will not be able to | access |
##  [text203, 131]                        and our google suite to | access |
##   [text230, 19] orientation chromebook distribution and Aeries | access |
##  [text331, 325]                             of the web page to | access |
##    [text414, 9]                   TECHNOLOGY ETC Click link to | access |
##  [text423, 123]           programs and providing free Internet | access |
##   [text448, 63]                 innovative way of learning and | access |
##   [text476, 88]                        using this link You can | access |
##                                       
##  Class Choice through your student    
##  on Monday August 3rd                 
##  the live lessons At the              
##  the learning platform Our middle     
##  for schedules                        
##  all information and updates Notices  
##  file with important information about
##  to serving millions of free          
##  to the internet This initiative      
##  breakfast and lunch menus using
kwic(my_tokens, "packet") %>% slice(1:10)
##                                                                   
##    [text89, 45]               of the meeting agenda and | packet |
##  [text1170, 24]       an AEC program their registration | packet |
##  [text1170, 33]               Check your email for this | packet |
##  [text1773, 19]         didn't pick up your culmination | packet |
##  [text1974, 20] school year Each student's registration | packet |
##  [text2174, 44]                 to pick up a substitute | packet |
##   [text2906, 5]                  BACK TO SCHOOL STUDENT | PACKET |
##  [text2906, 21]           your student's back to school | packet |
##  [text2906, 41]           your student's back to school | packet |
##  [text2906, 87]         High School Facebook pages This | packet |
##                              
##  This is an open meeting     
##  must be reutrned Check your 
##  complete return it to the   
##  you can come on Tuesdays    
##  tells us to expect that     
##  If you have any questions   
##  Click on the link to        
##  This year we are asking     
##  online You'll need to submit
##  is required for each student

Term co-occurence

not working with the entire dataset

my_fcm <- fcm(my_dfm)
feat <- names(topfeatures(my_fcm, 50))
my_fcm_select <- fcm_select(my_fcm, pattern = feat, selection = "keep")

size <- log(colSums(dfm_select(my_dfm, feat, selection = "keep")))
textplot_network(my_fcm_select, min_freq = 0.8, vertex_size = size / max(size) * 3,
                 edge_alpha = .3,
                 edge_size = 2)

Using regex

text <- ss %>% 
  select(message, year) %>% 
  collect() %>%  
  mutate(learning = str_detect(message, "(?i)learning"),
         technology = str_detect(message, "(?i)technology"),
         student = str_detect(message, "(?i)student"),
         education = str_detect(message, "(?i)education"),
         teaching = str_detect(message, "(?i)teaching"),
         online = str_detect(message, "(?i)online"),
         teacher = str_detect(message, "(?i)teacher"),
         covid = str_detect(message, "(?i)covid")) %>% 
  filter(!is.na(message))

text_to_plot <- text %>% 
  select(year, learning:covid) %>% 
  gather(key, val, -year) %>% 
  group_by(key, year) %>% 
  summarize(mean_val = mean(val, na.rm = TRUE))

text_to_plot %>% 
  filter(year >= 2010) %>% 
  ggplot(aes(x = year, y = mean_val, color = key, group = key)) +
  geom_point() +
  geom_line() +
  scale_color_brewer(type = "qual") +
  hrbrthemes::theme_ipsum() + 
  scale_x_continuous(breaks = 2010:2020) +
  ylab("proportion")

text <- tbl(cn, "posts") %>% 
  filter(year == 2020) %>% 
  select(message, month) %>% 
  collect() %>%  
  mutate(learning = str_detect(message, "(?i)learning"),
         technology = str_detect(message, "(?i)technology"),
         student = str_detect(message, "(?i)student"),
         education = str_detect(message, "(?i)education"),
         remote  = str_detect(message, "(?i)remote"),
         virtual = str_detect(message, "(?i)virtual"),
         remote = str_detect(message, "(?i)remote"),
         teacher = str_detect(message, "(?i)teacher"),
         meal = str_detect(message, "(?i)meal"),
         covid = str_detect(message, "(?i)covid")) %>% 
  filter(!is.na(message))

text_to_plot <- text %>% 
  select(month, learning:covid) %>% 
  gather(key, val, -month) %>% 
  group_by(key, month) %>% 
  summarize(mean_val = mean(val, na.rm = TRUE))

text_to_plot %>% 
  ggplot(aes(x = month, y = mean_val, color = key, group = key)) +
  geom_point() +
  geom_line() +
  scale_color_brewer(type = "qual") +
  hrbrthemes::theme_ipsum() + 
  scale_x_continuous(breaks = 1:9) +
  ylab("proportion")

Only for ST math, a digital tool (of the kind that may be used more during the pandemic); what other tools can we examine? some ideas here: https://www.educationnext.org/google-search-data-reveals-about-learning-pandemic/

text <- tbl(cn, "posts") %>% 
  filter(year == 2020) %>% 
  select(message, month) %>% 
  collect() %>%  
  filter(!is.na(message)) %>% 
  mutate(st_math= str_detect(message, "(?i)st math"))

text_to_plot <- text %>% 
  select(month, st_math) %>% 
  gather(key, val, -month) %>% 
  group_by(key, month) %>% 
  summarize(mean_val = sum(val, na.rm = TRUE))

text_to_plot %>% 
  ggplot(aes(x = month, y = mean_val, color = key, group = key)) +
  geom_point() +
  geom_line() +
  scale_color_brewer(type = "qual") +
  hrbrthemes::theme_ipsum() + 
  scale_x_continuous(breaks = 1:9) +
  ylab("proportion")

Photos

Not run just yet, working on API

ss_1000 <- tbl(cn, "posts") %>% 
  filter(year == 2020) %>% 
  select(facebook_id) %>% 
  collect() %>% 
  sample_n(1000)

files_to_download <- ss_collected %>% filter(type == "Photo") %>% pull(link) %>% head(5)

map2(files_to_download,
     str_c("downloaded-photos/", 1:5, ".jpeg"),
           download.file)