library(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.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── 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
library(janitor)
##
## Attaching package: 'janitor'
##
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
d1 <- read.csv("C:/Users/kinze/Downloads/maxdiff_dummy_data.csv")
head(d1)
## sorting from least popular to most popular
d1 <- d1 %>% arrange(maxdiff_mean)
d1 %>% ggplot(aes(maxdiff_mean)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## checking for normality quickly visually
qqnorm(d1$maxdiff_mean)
qqline(d1$maxdiff_mean)
## Standardizing data
d1 <- d1 %>% mutate(sigmas = scale(maxdiff_mean))
## selecting just the top and worse performing messages, sd of 1.5 chosen somewhat arbitrarily to get around 10% of responses on each end
d2<- d1 %>% filter(abs(sigmas)>1.5) %>%
mutate(bestworse = case_when(
sigmas < 0 ~ "poorly",
.default = "well")) %>% select(-c(sample_size, video_id))
## Warning: Using one column matrices in `filter()` was deprecated in dplyr 1.1.0.
## ℹ Please use one dimensional logical vectors instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
worst <- d2 %>% filter(bestworse =="poorly")
best <- d2 %>% filter(bestworse =="well")
The WORST PERFORMING
library(htmlTable)
htmlTable(worst$text)
| Donald Trump’s agenda would kill clean energy jobs in American communities by eliminating the tax credits that helped create thousands of new manufacturing jobs making solar panels and electric car parts. His stance is quite stark, and would leave clean energy in the dark. | Donald Trump wants to end programs that help you afford an electric car or solar panels - his policies make it harder for regular families to save money on gas and electricity. | Donald Trump plans to cut infrastructure money that would bring fast internet to rural areas, keeping millions of Americans stuck with slow or no internet access. | Donald Trump’s policy would cancel funding that helps communities install charging stations for electric cars, making it harder for Americans to switch to cheaper electric vehicles. | Donald Trump’s proposed policies would get rid of many workplace safety inspectors, meaning more workers could get hurt on the job without anyone checking if companies are following safety rules. When Trump is in charge, worker protection gets a discharge. His disregard for safety regulations puts everyday Americans at risk just to please his corporate allies. | Donald Trump wants to cancel funding for charging stations along highways, making it harder for Americans to switch to electric cars and save money on gas. | Donald Trump’s policies would end programs that help low-income families make their homes more energy efficient, forcing them to pay higher heating and cooling bills. When families can’t pay their bills and fall into debt, Donald Trump doesn’t care a bit. |
The BEST PERFORMING
htmlTable(best$text)
| Donald Trump wants to cut $880 billion from Medicaid in his budget, which would force millions of Americans to lose their health insurance that pays for doctor visits and medicine. | The Donald Trump budget would make harsh cuts to food stamps that would force parents to skip meals so their children can eat, by reducing food assistance by about $50 per week for the average family. | Donald Trump’s policies would force many disabled veterans to pay thousands more for their healthcare by reducing VA disability benefits they depend on. | Donald Trump’s proposed budget cuts to welfare programs would force over 1 million struggling families to lose money they need for basic things like rent, utilities, and clothes for their kids. | While families struggle with rising prices, Donald Trump’s policies give $4.5 trillion in tax cuts to the rich and big corporations - paid for by cutting food assistance and healthcare that working families need. | Donald Trump’s budget cuts would take away healthcare coverage from over 400,000 veterans who rely on Medicaid, leaving them without the medical care they earned serving our country. | The Donald Trump administration gave massive tax breaks to big corporations and billionaires, but made regular Americans pay more by cutting Medicare, Medicaid and other programs families depend on. |