source("Main.R")
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Warning in eval(ei, envir): NAs introduced by coercion
## Warning in eval(ei, envir): NAs introduced by coercion
ted_cruz_data<-republican_party_primary_polling|>filter(Candidate=="Ted Cruz")|>mutate(Poll_Boundary=ifelse(State=="NULL","Nationwide",State))
print(ted_cruz_data)
## Candidate Polling Pollster Nationwide State Sample_Size
## 1 Ted Cruz 4.0 Echelon Insights 1 NULL 932
## 2 Ted Cruz 5.0 Echelon Insights 1 NULL 483
## 3 Ted Cruz 4.0 Echelon Insights 1 NULL 466
## 4 Ted Cruz 5.0 Echelon Insights 1 NULL 457
## 5 Ted Cruz 2.0 YouGov/Economist 1 NULL 594
## 6 Ted Cruz 1.0 Echelon Insights 1 NULL 450
## 7 Ted Cruz 3.0 Yale Youth Poll 1 NULL NA
## 8 Ted Cruz 6.0 Club for Growth NULL Iowa 564
## 9 Ted Cruz 3.0 YouGov/Economist 1 NULL 1296
## 10 Ted Cruz 2.0 J.L. Partners 1 NULL 1006
## 11 Ted Cruz 4.0 Echelon Insights 1 NULL 426
## 12 Ted Cruz 6.0 J.L. Partners 1 NULL 975
## 13 Ted Cruz 0.5 Emerson College 1 NULL 416
## 14 Ted Cruz 1.0 Emerson College 1 NULL 420
## 15 Ted Cruz 2.4 Emerson College NULL North Carolina 416
## Voter_Type DMY
## 1 Registered Voters 2024-07-19
## 2 Likely Voters 2024-11-14
## 3 Likely Voters 2025-02-10
## 4 Likely Voters 2025-03-10
## 5 Registered Voters 2025-03-30
## 6 Likely Voters 2025-04-10
## 7 NULL 2025-04-01
## 8 Likely Voters 2025-04-14
## 9 NULL 2025-04-22
## 10 Registered Voters 2025-04-23
## 11 Likely Voters 2025-05-08
## 12 Registered Voters 2025-05-13
## 13 Registered Voters 2025-06-24
## 14 Registered Voters 2024-11-20
## 15 Likely Voters 2025-07-28
## Link
## 1 https://echeloninsights.com/in-the-news/july2024-verified-voter-omnibus-2-2-2-2/
## 2 https://echeloninsights.com/in-the-news/nov-2024-verified-voter-omnibus/
## 3 http://echelonin.wpenginepowered.com/wp-content/uploads/February-2025-Voter-Omnibus-Topline-External.pdf
## 4 https://echeloninsights.com/in-the-news/march-2025-verified-voter-omnibus-2-2-2/
## 5 https://d3nkl3psvxxpe9.cloudfront.net/documents/econtoplines_S1a74K0.pdf
## 6 https://echeloninsights.com/in-the-news/april-2025-verified-voter-omnibus-2-2-2-2/
## 7 https://docs.google.com/spreadsheets/d/1JhSWPVcKK6tdufsa52TeRk3JRwSsgtglVQP1ZAa8fg4/edit?gid=396464130#gid=396464130
## 8 https://x.com/axiosalex/status/1912612448898626028
## 9 https://d3nkl3psvxxpe9.cloudfront.net/documents/times_20250425.pdf
## 10 https://floridapolitics.com/archives/735360-desantis-poll-28/
## 11 https://echeloninsights.com/in-the-news/may-2025-verified-voter-omnibus-2-2-2-2-2/
## 12 https://www.telegraph.co.uk/us/politics/2025/05/16/jd-vance-is-runaway-republican-candidate-polling-reveal/
## 13 https://emersoncollegepolling.com/june-national-poll/
## 14 https://emersoncollegepolling.com/november-2024-national-poll-trump-favorability-jumps-post-election-2028-election-kicks-off-with-harris-and-vance-leading-primaries/
## 15 https://emersoncollegepolling.com/north-carolina-2026-poll-cooper-starts-us-senate-race-with-six-point-lead-and-clear-name-recognition-advantage-over-whatley/
## Poll_Boundary
## 1 Nationwide
## 2 Nationwide
## 3 Nationwide
## 4 Nationwide
## 5 Nationwide
## 6 Nationwide
## 7 Nationwide
## 8 Iowa
## 9 Nationwide
## 10 Nationwide
## 11 Nationwide
## 12 Nationwide
## 13 Nationwide
## 14 Nationwide
## 15 North Carolina
ted_cruz_chart<-ted_cruz_data|>ggplot(aes(x=DMY,y=Polling,color=Poll_Boundary))+geom_point(alpha=0.6)+geom_line()+scale_x_date(date_breaks="3 months")+labs(title="Ted Cruz",x="Date",y="Polling (%)")
print(ted_cruz_chart)

ted_cruz_summary<-ted_cruz_data|>summarise(avg_polling=round(mean(Polling),digits=2),weighted_avg_polling=round(sum(Polling * Sample_Size/(sum(Sample_Size,na.rm=TRUE)),na.rm=TRUE),digits=2),
standard_deviation=round(sd(Polling),digits=2),maximum_polling=max(Polling),minimum_polling=min(Polling),median_polling=median(Polling))
print(ted_cruz_summary)
## avg_polling weighted_avg_polling standard_deviation maximum_polling
## 1 3.26 3.41 1.78 6
## minimum_polling median_polling
## 1 0.5 3