slpreselection

Presidential Election data of Sri Lanka from 1982 to 2015.

https://github.com/amalan-constat/slpreselection

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: researchgate.net
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.9%) to scientific vocabulary

Keywords

presidential-election r-package sri-lanka
Last synced: 10 months ago · JSON representation

Repository

Presidential Election data of Sri Lanka from 1982 to 2015.

Basic Info
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
presidential-election r-package sri-lanka
Created over 3 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,comment = "#>",collapse = TRUE, fig.retina=2, fig.path = "man/figures/",
                      out.width = "100%",warning = FALSE,message = FALSE)
library(badger)
```

# SLPresElection 




`r badge_cran_release("SLPresElection")`
`r badge_cran_checks("SLPresElection")`
`r badge_runiverse()`

`r badge_cran_download("SLPresElection", "grand-total", "green")`
`r badge_cran_download("SLPresElection", "last-month", "green")`
`r badge_cran_download("SLPresElection", "last-week", "green")`

`r badge_repostatus("Active")`
`r badge_lifecycle("stable")`
[![GitHub issues](https://img.shields.io/github/issues/Amalan-ConStat/SLPresElection.svg?style=popout)](https://github.com/Amalan-ConStat/SLPresElection/issues)

[![Codecov test coverage](https://codecov.io/gh/Amalan-ConStat/SLPresElection/branch/main/graph/badge.svg)](https://app.codecov.io/gh/Amalan-ConStat/SLPresElection?branch=main)
`r badge_codefactor("Amalan-ConStat/SLPresElection")`
`r badge_code_size("Amalan-ConStat/SLPresElection")`

[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)


## How to engage with "SLPresElection" the first time ? 

```{r SLPresElection from GitHub or CRAN,eval=FALSE}
## Installing the package from GitHub
devtools::install_github("Amalan-ConStat/SLPresElection")

## Installing the package from CRAN
install.packages("SLPresElection")
```

## Key Phrases
* Presidential Election
* District
* Electorate
* Postal Votes
* Displaced Votes
* Total No of Valid Votes (Total Valid)
* No of Rejected Votes (Total Rejected)
* Total No of Votes Polled (Total Polled)
* No of Registered Electors (Total Registered)

```{r Load,quietly = TRUE}
#Load necessary packages
library(SLPresElection); library(ggplot2); library(dplyr); 
library(viridisLite); library(ggthemr); ggthemr("flat dark")
```

## What does "SLPresElection" ?

The seven presidential election results of Sri Lanka from 1982 to 2015 are available in the election commission [website as pdf files](https://elections.gov.lk/web/en/elections/elections-results/presidential-elections-results/).
However, through pdf scraping these results are available as csv files because of [my pet project](https://github.com/Amalan-ConStat/PresidentialElection). 
These csv files are available as data-frames in this R package.

Something to ponder on the tables in these pdf files
1. Total Polled = Total Valid + Total Rejected
2. Total Valid = Votes casted to Candidate $A$ + $...$ + Votes casted to Candidate $Z$
3. Total Polled $%$ = (Total Polled/ Total Registered) * $100$ 
4. Total Valid $%$ = (Total Valid/ Total Polled) * $100$
5. Total Rejected $%$ = (Total Rejected/ Total Polled) * $100$
6. Candidate $i$ $%$ = (Candidate A/ Total Polled ) *$100$

## Just a glimpse

```{r Registered_and_Polled_Votes,fig.width=12,fig.height=8,quietly = TRUE}
Election1982 %>% 
  subset(ColNames=="No of Registered Electors" & Electorate=="Final District Results"| 
         ColNames=="Total No of Votes Polled" & Electorate=="Final District Results")  %>% 
  group_by(District,ColNames) %>%
  summarise(Votes=sum(Votes)/100000) %>%
  ungroup(District,ColNames) %>%
  ggplot(.,aes(x=District,y=Votes,fill=ColNames,label=round(Votes,4)))+
  ylab("Votes (in 100,000)")+xlab("District")+
  geom_col(position = "dodge")+
  geom_text(vjust=-1,size=3)+
  theme(legend.position = "bottom",
        axis.text.x = element_text(angle=45,vjust=1.2,hjust=1.1))+
  scale_fill_viridis_d()+
  ggtitle("For 1982 the registered and polled votes for all districts")

```

```{r All seven elections,quietly = TRUE}
Final_Data<-rbind.data.frame(Election1982,Election1988,
                             Election1994,Election1999,
                             Election2005,Election2010,Election2015)
years<-unique(Final_Data$Year)
```

```{r Registered_and_Polled_Votes_over_the_years,fig.width=12,fig.height=8,quietly = TRUE}
Final_Data %>%
  subset(ColNames=="No of Registered Electors" & Electorate=="Final District Results" | 
           ColNames=="Total No of Votes Polled" & Electorate=="Final District Results") %>%
  group_by(Year,ColNames) %>%
  summarise(Votes=sum(Votes)/100000) %>%
  ungroup(Year,ColNames) %>%
  ggplot(.,aes(Year,Votes,color=ColNames,label=Votes))+
  ylab("Votes (in 100,000)")+
  geom_point(size=3.5)+geom_line(linewidth=2)+
  geom_text(vjust=-1.25,size=4)+
  scale_x_continuous(breaks = years)+
  theme(legend.position = "bottom")+scale_color_viridis_d()+
  ggtitle("The registered and polled votes for all seven elections")
```

```{r Rejected_Votes_over_the_years,fig.width=8,fig.height=6,quietly = TRUE}
Final_Data %>%
  subset(ColNames=="No of Rejected Votes" & Electorate=="Final District Results") %>%
  group_by(Year,ColNames) %>%
  summarise(Votes=sum(Votes)/100000) %>%
  ungroup(Year,ColNames) %>%
  ggplot(.,aes(Year,Votes,label=Votes))+
  geom_col()+geom_text(vjust=1)+
  ylab("Votes (in 100,000)")+
  scale_x_continuous(breaks = years)+
  theme(legend.position = "bottom")+scale_color_viridis_d()+
  ggtitle("No of Rejected Votes Over the Years")
```

## Conclusion

Complete information about how the data was scraped from the pdf files are available at the github repository [Presidential Election Data](https://github.com/Amalan-ConStat/PresidentialElection).
Read this blog post ["Extract Presidential Election Data of 2015 from the Pdf file"](https://amalan-con-stat.netlify.app/post/slelection/presidential-election/2015/2015/) for a clear picture of how to scrape the data from pdf files.
Results of all elections occured in Sri Lanka are available at the [Election Commission website](https://elections.gov.lk/)

#### Thank You

[![Twitter](https://img.shields.io/twitter/url/https/github.com/Amalan-ConStat/SLPresElection.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2FAmalan-ConStat%2FSLPresElection)

[ ![](https://img.shields.io/badge/LinkedIn-Amalan%20Mahendran-black.svg?style=flat) ]( https://www.linkedin.com/in/amalan-mahendran-72b86b37/)
[ ![](https://img.shields.io/badge/Research%20Gate-Amalan%20Mahendran-black.svg?style=flat) ]( https://www.researchgate.net/profile/Amalan_Mahendran )

Owner

  • Name: M. Amalan
  • Login: Amalan-ConStat
  • Kind: user
  • Location: Kandy, Sri Lanka and Brisbane, Australia
  • Company: QUT

Well, I am a statistician with practices in R statistical programming. Interests include R packages, Rmarkdown Reports, Rshiny Apps and #TidyTuesday.

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 195 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
cran.r-project.org: SLPresElection

Presidential Election Data of "Sri Lanka" from 1982 to 2015

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 195 Last month
Rankings
Forks count: 28.8%
Dependent packages count: 29.8%
Stargazers count: 31.7%
Dependent repos count: 35.5%
Average: 38.5%
Downloads: 66.6%
Maintainers (1)
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • R >= 4.0.0 depends
  • spelling * suggests
  • testthat * suggests