## Reading layer `uttarpradesh.assembly' from data source 
##   `D:\R Manan\uttarpradesh.assembly.shp' using driver `ESRI Shapefile'
## Simple feature collection with 402 features and 5 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: 77.08491 ymin: 23.87277 xmax: 84.6306 ymax: 30.41246
## Geodetic CRS:  WGS 84
## Reading layer `karnataka.assembly' from data source 
##   `D:\R Manan\karnataka.assembly.shp' using driver `ESRI Shapefile'
## Simple feature collection with 205 features and 5 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 74.05431 ymin: 11.57448 xmax: 78.57747 ymax: 18.45512
## Geodetic CRS:  WGS 84

Preliminary Electorate Analysis

## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

## Scale for y is already present.
## Adding another scale for y, which will replace the existing scale.

## `summarise()` has grouped output by 'Year'. You can override using the
## `.groups` argument.

## `summarise()` has grouped output by 'Year'. You can override using the
## `.groups` argument.

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## 
## =================================================
##                           Dependent variable:    
##                       ---------------------------
##                           Turnout_change_pct     
## -------------------------------------------------
## Electorate_change_pct          0.976***          
##                                 (0.023)          
##                                                  
## Constant                       3.992***          
##                                 (0.410)          
##                                                  
## -------------------------------------------------
## Observations                     7,109           
## R2                               0.199           
## Adjusted R2                      0.198           
## Residual Std. Error       26.722 (df = 7107)     
## F Statistic           1,760.489*** (df = 1; 7107)
## =================================================
## Note:                 *p<0.1; **p<0.05; ***p<0.01
## 
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                         change_valid_votes     
## -----------------------------------------------
## change_electors              0.541***          
##                               (0.037)          
##                                                
## Constant                   37,871.400***       
##                             (5,997.347)        
##                                                
## -----------------------------------------------
## Observations                    522            
## R2                             0.291           
## Adjusted R2                    0.289           
## Residual Std. Error    61,066.350 (df = 520)   
## F Statistic          213.073*** (df = 1; 520)  
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

## New names:
## Grand total (raw cell, parsed): 977965560
## New names:
## Using state column: STATE/UT and grand total column: TOTAL...17
## ⚠️ 2024 rows with NA/0 Electors (inspect these):
## • `` -> `...1`
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
## • `` -> `...16`
## • `` -> `...17`
## # A tibble: 10 × 3
##    State_Name              Electors  Year
##    <chr>                      <dbl> <int>
##  1 Arunachal_Pradesh              0  2024
##  2 Manipur                        0  2024
##  3 Mizoram                        0  2024
##  4 Nagaland                       0  2024
##  5 Sikkim                         0  2024
##  6 Tripura                        0  2024
##  7 Andaman_Nicobar_Islands        0  2024
##  8 Lakshadweep                    0  2024
##  9 Jammu_and_Kashmir              0  2024
## 10 Ladakh                         0  2024
## Sum of parsed per-state 2024 electors: 238748
## Grand total from sheet cell (Row40,Col13): 977965560
## Difference (cell - sum states) = 977726812
## National totals (last few rows):
## # A tibble: 5 × 2
##    Year  Electors
##   <int>     <dbl>
## 1  2004 671487930
## 2  2009 716985101
## 3  2014 834082814
## 4  2019 911950734
## 5  2024 977965560
## Nation derived from cell vs statesum: difference = 977726812
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

## New names:
## • `Total` -> `Total...5`
## • `Total` -> `Total...8`
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

## Rows: 91669 Columns: 45
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (19): State_Name, Candidate, Sex, Party, Candidate_Type, Constituency_Na...
## dbl (20): Assembly_No, Constituency_No, Year, month, Poll_No, DelimID, Posit...
## lgl  (6): last_poll, Same_Constituency, Same_Party, Turncoat, Incumbent, Rec...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
##  [1] "State_Name"             "Assembly_No"            "Constituency_No"       
##  [4] "Year"                   "month"                  "Poll_No"               
##  [7] "DelimID"                "Position"               "Candidate"             
## [10] "Sex"                    "Party"                  "Votes"                 
## [13] "Candidate_Type"         "Valid_Votes"            "Electors"              
## [16] "Constituency_Name"      "Constituency_Type"      "Sub_Region"            
## [19] "N_Cand"                 "Turnout_Percentage"     "Vote_Share_Percentage" 
## [22] "Deposit_Lost"           "Margin"                 "Margin_Percentage"     
## [25] "ENOP"                   "pid"                    "Party_Type_TCPD"       
## [28] "Party_ID"               "last_poll"              "Contested"             
## [31] "Last_Party"             "Last_Party_ID"          "Last_Constituency_Name"
## [34] "Same_Constituency"      "Same_Party"             "No_Terms"              
## [37] "Turncoat"               "Incumbent"              "Recontest"             
## [40] "MyNeta_education"       "TCPD_Prof_Main"         "TCPD_Prof_Main_Desc"   
## [43] "TCPD_Prof_Second"       "TCPD_Prof_Second_Desc"  "Election_Type"
## New names:
## • `Total` -> `Total...5`
## • `Total` -> `Total...8`
## [1] "NAME OF State/UT"         "Polling Stations"        
## [3] "GENERAL (INCLUDING NRIs)" "SERVICE"                 
## [5] "Total...5"                "EVM"                     
## [7] "POSTAL"                   "Total...8"               
## [9] "VTR %"
## Warning: Removed 10 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 10 rows containing missing values or values outside the scale range
## (`geom_point()`).

## 
## Electorate Size % Change     Voter Turnout Change 
##                       90                       95

Assembly Election Analysis

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

##Electorate Analysis of Indian State Uttar Pradesh & Karnataka

## `summarise()` has grouped output by 'Year'. You can override using the
## `.groups` argument.
## # A tibble: 5 × 3
## # Groups:   Year [1]
##    Year Constituency_Name Turnout
##   <int> <chr>               <dbl>
## 1  2023 MELUKOTE             90.9
## 2  2023 HOSAKOTE             90.9
## 3  2023 NAGAMANGALA          89.0
## 4  2023 MALUR                89.0
## 5  2023 GUBBI                88.9
## # A tibble: 5 × 3
## # Groups:   Year [1]
##    Year Constituency_Name Turnout
##   <int> <chr>               <dbl>
## 1  2023 C.V. RAMAN NAGAR     47.4
## 2  2023 B.T.M LAYOUT         49.2
## 3  2023 BOMMANAHALLI         49.5
## 4  2023 DASARAHALLI          50.2
## 5  2023 BANGALORE SOUTH      51.6
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

## # A tibble: 4 × 3
##    Year AE_Electors GE_Electors
##   <dbl>       <dbl>       <dbl>
## 1  2004    25651989    25651989
## 2  2009    27194864    27194864
## 3  2014    29196047    29196045
## 4  2019    32252383    32497762
## # A tibble: 5 × 5
##    Year AE_Electors GE_Electors Elector_Diff Elector_Ratio
##   <dbl>       <dbl>       <dbl>        <dbl>         <dbl>
## 1  2004    25651989    25651989            0         1    
## 2  2009    27194864    27194864            0         1    
## 3  2014    29196047    29196045            2         1.00 
## 4  2019    32252383    32497762      -245379         0.992
## 5  2024    33716965    33716965            0         1

## Rows: 403
## Columns: 3
## $ Constituency_Name <chr> "BEHAT", "NAKUR", "SAHARANPUR NAGAR", "SAHARANPUR", …
## $ Electors2012      <int> 303273, 298985, 349364, 276294, 292273, 266686, 3172…
## $ Electors2022      <int> 372728, 355840, 445458, 358965, 349384, 324347, 3865…

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: There was 1 warning in `summarise()`.
## ℹ In argument: `Electors = max(Electors, na.rm = TRUE)`.
## ℹ In group 3922: `Year = 1993` and `Constituency_Name = "GHAZIPUR"`.
## Caused by warning in `max()`:
## ! no non-missing arguments to max; returning -Inf

Electorate and Congress Voteshare Analysis

## 
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                        Cong_VoteShare_Change   
## -----------------------------------------------
## Electorate_Change             -0.012           
##                               (0.017)          
##                                                
## Constant                      -0.344           
##                               (0.299)          
##                                                
## -----------------------------------------------
## Observations                   3,309           
## R2                            0.0001           
## Adjusted R2                   -0.0002          
## Residual Std. Error     12.819 (df = 3307)     
## F Statistic            0.469 (df = 1; 3307)    
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01
## 
##  Pearson's product-moment correlation
## 
## data:  cleaned$Electorate_Change and cleaned$Cong_VoteShare_Change
## t = 4.272, df = 6504, p-value = 0.00001965
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.02863381 0.07709784
## sample estimates:
##        cor 
## 0.05289698

## 
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                        Cong_VoteShare_Change   
## -----------------------------------------------
## Electorate_Change            -0.017**          
##                               (0.007)          
##                                                
## Constant                      -0.100           
##                               (0.162)          
##                                                
## -----------------------------------------------
## Observations                  21,811           
## R2                            0.0003           
## Adjusted R2                   0.0002           
## Residual Std. Error     16.767 (df = 21809)    
## F Statistic           5.757** (df = 1; 21809)  
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01
## 
##  Pearson's product-moment correlation
## 
## data:  cleaned_ae$Electorate_Change and cleaned_ae$Cong_VoteShare_Change
## t = -7.7978, df = 44755, p-value = 0.000000000000006433
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.04608355 -0.02757979
## sample estimates:
##         cor 
## -0.03683483
## 
## Regression of Congress Vote Share Change on Electorate Change
## =====================================================================================
##                                           Dependent variable:                        
##                   -------------------------------------------------------------------
##                                       Congress Vote Share Change                     
##                   1st Party System 2nd Party System 3rd Party System 4th Party System
##                         (1)              (2)              (3)              (4)       
## -------------------------------------------------------------------------------------
## Electorate Change    0.0000***          0.002            -0.01            0.02*      
##                       (0.0000)          (0.01)           (0.01)           (0.01)     
##                                                                                      
## Constant                0.01            -0.15             0.09            -0.02      
##                        (0.43)           (0.29)           (0.28)           (0.41)     
##                                                                                      
## -------------------------------------------------------------------------------------
## Observations            979             1,926            2,294             849       
## R2                      0.02            0.0000           0.001            0.004      
## Adjusted R2             0.02           -0.0005           0.0003           0.003      
## =====================================================================================
## Note:                                                     *p<0.1; **p<0.05; ***p<0.01
## 
## Regression of Congress Vote Share Change on Electorate Change fo assembly elections
## =====================================================================================
##                                           Dependent variable:                        
##                   -------------------------------------------------------------------
##                                       Congress Vote Share Change                     
##                   1st Party System 2nd Party System 3rd Party System 4th Party System
##                         (1)              (2)              (3)              (4)       
## -------------------------------------------------------------------------------------
## Electorate Change      -0.01           -0.02***         -0.02***         -0.05***    
##                        (0.01)           (0.01)          (0.004)           (0.01)     
##                                                                                      
## Constant                0.01             0.04             0.10             0.18      
##                        (0.22)           (0.14)           (0.13)           (0.27)     
##                                                                                      
## -------------------------------------------------------------------------------------
## Observations           6,358            16,150           15,590           3,756      
## R2                     0.0000           0.001            0.002             0.01      
## Adjusted R2           -0.0001           0.001            0.002             0.01      
## =====================================================================================
## Note:                                                     *p<0.1; **p<0.05; ***p<0.01

## Warning: Removed 6 rows containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).
## Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_line()`).
## Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'

## Rows: 91669 Columns: 45
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (19): State_Name, Candidate, Sex, Party, Candidate_Type, Constituency_Na...
## dbl (20): Assembly_No, Constituency_No, Year, month, Poll_No, DelimID, Posit...
## lgl  (6): last_poll, Same_Constituency, Same_Party, Turncoat, Incumbent, Rec...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## New names:
## New names:
##  [1] "SL. NO."    "STATE/UT"   "M...3"      "F...4"      "TG...5"    
##  [6] "TOTAL...6"  "M...7"      "F...8"      "TOTAL...9"  "M...10"    
## [11] "F...11"     "TG...12"    "TOTAL...13" "M...14"     "F...15"    
## [16] "TG...16"    "TOTAL...17"