{"id":32200930,"url":"https://github.com/amalan-constat/slpreselection","last_synced_at":"2025-10-22T03:57:28.024Z","repository":{"id":65336803,"uuid":"583794722","full_name":"Amalan-ConStat/SLPresElection","owner":"Amalan-ConStat","description":"Presidential Election data of Sri Lanka from 1982 to 2015.","archived":false,"fork":false,"pushed_at":"2024-10-11T03:31:46.000Z","size":1887,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-22T03:57:25.892Z","etag":null,"topics":["presidential-election","r-package","sri-lanka"],"latest_commit_sha":null,"homepage":"https://amalan-constat.github.io/SLPresElection/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Amalan-ConStat.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-12-31T00:08:23.000Z","updated_at":"2024-10-11T03:31:50.000Z","dependencies_parsed_at":"2025-09-08T16:34:12.501Z","dependency_job_id":null,"html_url":"https://github.com/Amalan-ConStat/SLPresElection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Amalan-ConStat/SLPresElection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amalan-ConStat%2FSLPresElection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amalan-ConStat%2FSLPresElection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amalan-ConStat%2FSLPresElection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amalan-ConStat%2FSLPresElection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Amalan-ConStat","download_url":"https://codeload.github.com/Amalan-ConStat/SLPresElection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amalan-ConStat%2FSLPresElection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280376547,"owners_count":26320275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["presidential-election","r-package","sri-lanka"],"created_at":"2025-10-22T03:57:27.175Z","updated_at":"2025-10-22T03:57:28.017Z","avatar_url":"https://github.com/Amalan-ConStat.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE,comment = \"#\u003e\",collapse = TRUE, fig.retina=2, fig.path = \"man/figures/\",\n                      out.width = \"100%\",warning = FALSE,message = FALSE)\nlibrary(badger)\n```\n\n# SLPresElection \u003cimg src=\"man/figures/logo.png\" align=\"right\" alt=\"\" width=\"150\" /\u003e\n\n\u003c!-- badges: start --\u003e\n\n\n`r badge_cran_release(\"SLPresElection\")`\n`r badge_cran_checks(\"SLPresElection\")`\n`r badge_runiverse()`\n\n`r badge_cran_download(\"SLPresElection\", \"grand-total\", \"green\")`\n`r badge_cran_download(\"SLPresElection\", \"last-month\", \"green\")`\n`r badge_cran_download(\"SLPresElection\", \"last-week\", \"green\")`\n\n`r badge_repostatus(\"Active\")`\n`r badge_lifecycle(\"stable\")`\n[![GitHub issues](https://img.shields.io/github/issues/Amalan-ConStat/SLPresElection.svg?style=popout)](https://github.com/Amalan-ConStat/SLPresElection/issues)\n\n[![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)\n`r badge_codefactor(\"Amalan-ConStat/SLPresElection\")`\n`r badge_code_size(\"Amalan-ConStat/SLPresElection\")`\n\n[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)\n\u003c!-- badges: end --\u003e\n\n## How to engage with \"SLPresElection\" the first time ? \n\n```{r SLPresElection from GitHub or CRAN,eval=FALSE}\n## Installing the package from GitHub\ndevtools::install_github(\"Amalan-ConStat/SLPresElection\")\n\n## Installing the package from CRAN\ninstall.packages(\"SLPresElection\")\n```\n\n## Key Phrases\n* Presidential Election\n* District\n* Electorate\n* Postal Votes\n* Displaced Votes\n* Total No of Valid Votes (Total Valid)\n* No of Rejected Votes (Total Rejected)\n* Total No of Votes Polled (Total Polled)\n* No of Registered Electors (Total Registered)\n\n```{r Load,quietly = TRUE}\n#Load necessary packages\nlibrary(SLPresElection); library(ggplot2); library(dplyr); \nlibrary(viridisLite); library(ggthemr); ggthemr(\"flat dark\")\n```\n\n## What does \"SLPresElection\" ?\n\nThe 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/).\nHowever, through pdf scraping these results are available as csv files because of [my pet project](https://github.com/Amalan-ConStat/PresidentialElection). \nThese csv files are available as data-frames in this R package.\n\nSomething to ponder on the tables in these pdf files\n1. Total Polled = Total Valid + Total Rejected\n2. Total Valid = Votes casted to Candidate $A$ + $...$ + Votes casted to Candidate $Z$\n3. Total Polled $%$ = (Total Polled/ Total Registered) * $100$ \n4. Total Valid $%$ = (Total Valid/ Total Polled) * $100$\n5. Total Rejected $%$ = (Total Rejected/ Total Polled) * $100$\n6. Candidate $i$ $%$ = (Candidate A/ Total Polled ) *$100$\n\n## Just a glimpse\n\n```{r Registered_and_Polled_Votes,fig.width=12,fig.height=8,quietly = TRUE}\nElection1982 %\u003e% \n  subset(ColNames==\"No of Registered Electors\" \u0026 Electorate==\"Final District Results\"| \n         ColNames==\"Total No of Votes Polled\" \u0026 Electorate==\"Final District Results\")  %\u003e% \n  group_by(District,ColNames) %\u003e%\n  summarise(Votes=sum(Votes)/100000) %\u003e%\n  ungroup(District,ColNames) %\u003e%\n  ggplot(.,aes(x=District,y=Votes,fill=ColNames,label=round(Votes,4)))+\n  ylab(\"Votes (in 100,000)\")+xlab(\"District\")+\n  geom_col(position = \"dodge\")+\n  geom_text(vjust=-1,size=3)+\n  theme(legend.position = \"bottom\",\n        axis.text.x = element_text(angle=45,vjust=1.2,hjust=1.1))+\n  scale_fill_viridis_d()+\n  ggtitle(\"For 1982 the registered and polled votes for all districts\")\n\n```\n\n```{r All seven elections,quietly = TRUE}\nFinal_Data\u003c-rbind.data.frame(Election1982,Election1988,\n                             Election1994,Election1999,\n                             Election2005,Election2010,Election2015)\nyears\u003c-unique(Final_Data$Year)\n```\n\n```{r Registered_and_Polled_Votes_over_the_years,fig.width=12,fig.height=8,quietly = TRUE}\nFinal_Data %\u003e%\n  subset(ColNames==\"No of Registered Electors\" \u0026 Electorate==\"Final District Results\" | \n           ColNames==\"Total No of Votes Polled\" \u0026 Electorate==\"Final District Results\") %\u003e%\n  group_by(Year,ColNames) %\u003e%\n  summarise(Votes=sum(Votes)/100000) %\u003e%\n  ungroup(Year,ColNames) %\u003e%\n  ggplot(.,aes(Year,Votes,color=ColNames,label=Votes))+\n  ylab(\"Votes (in 100,000)\")+\n  geom_point(size=3.5)+geom_line(linewidth=2)+\n  geom_text(vjust=-1.25,size=4)+\n  scale_x_continuous(breaks = years)+\n  theme(legend.position = \"bottom\")+scale_color_viridis_d()+\n  ggtitle(\"The registered and polled votes for all seven elections\")\n```\n\n```{r Rejected_Votes_over_the_years,fig.width=8,fig.height=6,quietly = TRUE}\nFinal_Data %\u003e%\n  subset(ColNames==\"No of Rejected Votes\" \u0026 Electorate==\"Final District Results\") %\u003e%\n  group_by(Year,ColNames) %\u003e%\n  summarise(Votes=sum(Votes)/100000) %\u003e%\n  ungroup(Year,ColNames) %\u003e%\n  ggplot(.,aes(Year,Votes,label=Votes))+\n  geom_col()+geom_text(vjust=1)+\n  ylab(\"Votes (in 100,000)\")+\n  scale_x_continuous(breaks = years)+\n  theme(legend.position = \"bottom\")+scale_color_viridis_d()+\n  ggtitle(\"No of Rejected Votes Over the Years\")\n```\n\n## Conclusion\n\nComplete 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).\nRead 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.\nResults of all elections occured in Sri Lanka are available at the [Election Commission website](https://elections.gov.lk/)\n\n#### Thank You\n\n[![Twitter](https://img.shields.io/twitter/url/https/github.com/Amalan-ConStat/SLPresElection.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:\u0026url=https%3A%2F%2Fgithub.com%2FAmalan-ConStat%2FSLPresElection)\n\n[ ![](https://img.shields.io/badge/LinkedIn-Amalan%20Mahendran-black.svg?style=flat) ]( https://www.linkedin.com/in/amalan-mahendran-72b86b37/)\n[ ![](https://img.shields.io/badge/Research%20Gate-Amalan%20Mahendran-black.svg?style=flat) ]( https://www.researchgate.net/profile/Amalan_Mahendran )\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famalan-constat%2Fslpreselection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famalan-constat%2Fslpreselection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famalan-constat%2Fslpreselection/lists"}