library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.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
library(readxl)
library(pastecs)
##
## Attaching package: 'pastecs'
##
## The following objects are masked from 'package:dplyr':
##
## first, last
##
## The following object is masked from 'package:tidyr':
##
## extract
library(dplyr)
data1<-(X2020Election[-1,])
Elections <- read_xlsx("2024Elections.xlsx")
## New names:
## • `` -> `...4`
Elections2024<- (Elections[-1,])
#removes United States total row
Elections2024$INELIGIBLE_FELONS_TOTAL<- parse_number(Elections2024$INELIGIBLE_FELONS_TOTAL)
#Elections2024$INELIGIBLE_FELONS_TOTAL <- as.numeric(Elections2024$INELIGIBLE_FELONS_TOTAL)
#Elections2024$INELIGIBLE_FELONS_TOTAL <- as.numeric(Elections2024$INELIGIBLE_FELONS_TOTAL)
#MutantElections2024<- Elections2024 %>% mutate(INELIGIBLE_FELONS_TOTAL) = as.numeric(INELIGIBLE_FELONS_TOTAL)
pastecs::stat.desc(Elections2024$INELIGIBLE_FELONS_TOTAL)
## nbr.val nbr.null nbr.na min max range
## 5.100000e+01 3.000000e+00 0.000000e+00 0.000000e+00 4.857810e+05 4.857810e+05
## sum median mean SE.mean CI.mean.0.95 var
## 2.373735e+06 1.641200e+04 4.654382e+04 1.110335e+04 2.230174e+04 6.287504e+09
## std.dev coef.var
## 7.929378e+04 1.703637e+00
CleanElections<- Elections2024 |>drop_na(INELIGIBLE_FELONS_TOTAL) %>%filter(INELIGIBLE_FELONS_TOTAL>0)
#district_clean<- district |>drop_na(DPSTURNR) %>%filter(DPSTURNR>0)
hist(CleanElections$INELIGIBLE_FELONS_TOTAL)
CleanElections<- CleanElections %>% mutate(IFT_SQRT=sqrt(INELIGIBLE_FELONS_TOTAL))
hist(CleanElections$IFT_SQRT)