title: “Week 14 Lab” author: “Dylan Simmons” date: “2024-04-19” output: html_document

`

if (!require("tidyverse")) install.packages("tidyverse")
## Loading required package: tidyverse
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
if (!require("tidytext")) install.packages("tidytext")
## Loading required package: tidytext
library(tidyverse)
library(tidytext)

mydata <- read.csv("https://raw.githubusercontent.com/drkblake/Data/main/TNBills22_23.csv")

tidy_text <- mydata %>% 
  unnest_tokens(word,description) %>% 
  count(word, sort = TRUE)

# Deleting standard stop words
data("stop_words")
tidy_text <- tidy_text %>%
  anti_join(stop_words)
## Joining with `by = join_by(word)`
# Deleting custom stop words
my_stopwords <- tibble(word = c("https",
                                "t.co",
                                "rt"))
tidy_text <- tidy_text %>% 
  anti_join(my_stopwords)
## Joining with `by = join_by(word)`
searchterms <- "School|education|child|program"
mydata$School <- ifelse(grepl(searchterms,
                             mydata$description,
                             ignore.case = TRUE),1,0)
sum(mydata$School)
## [1] 293
sum(mydata$School)/1470
## [1] 0.1993197

I believe that the most popular type of bill passed were those that dealt with school. For my research, I used school, education, child, and program as search terms to help find how many times school was referenced. In total, nearly 20% of bills dealt with school or topics that were in the same frame. As a result of this, it is hard to say that any other bills could reach that same share of the bills considering how many different topics that the legislature deals with. Therefore, I believe that school is the most popular topic when it comes to passing bills.