Skip to content

Commit

Permalink
added 당원수
Browse files Browse the repository at this point in the history
  • Loading branch information
statkclee committed Dec 2, 2023
2 parents 5e30c49 + 2f52be3 commit c463a09
Show file tree
Hide file tree
Showing 15 changed files with 218 additions and 0 deletions.
Binary file modified Rplot001.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ website:
text: "투개표 API"
- href: single_member.qmd
text: "양당과 소선구제"
- href: proportion_member.qmd
text: "비례 국회의원"
- href: best_matches.qmd
text: "최고 관심 격돌"


format:
html:
Expand Down
89 changes: 89 additions & 0 deletions best_matches.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: "지도제작 대회"
subtitle: "최고 관심 격돌"
description: |
최고 관심 격돌 선거전을 살펴보자.
author:
- name: 이광춘
url: https://www.linkedin.com/in/kwangchunlee/
affiliation: 한국 R 사용자회
affiliation-url: https://github.com/bit2r
title-block-banner: true
format:
html:
theme: flatly
code-fold: true
code-overflow: wrap
toc: true
toc-depth: 3
toc-title: 목차
number-sections: true
highlight-style: github
self-contained: false
default-image-extension: jpg
filters:
- lightbox
lightbox: auto
link-citations: true
knitr:
opts_chunk:
eval: true
message: false
warning: false
collapse: true
comment: "#>"
R.options:
knitr.graphics.auto_pdf: true
editor_options:
chunk_output_type: console
---

```{r}
#| include: false
library(tidyverse)
library(rvest)
library(httr)
library(sf)
library(geogrid)
```


# 최고의 빅매치


- 제18대 (2008년) 정몽준 vs 정동영
- [정몽준-정동영 동작을 맞붙나](https://www.hani.co.kr/arti/politics/politics_general/275957.html)
- 제18대 (2008년) 노회찬 vs 홍정욱
- [노회찬(강북좌파), 홍정욱(강남우파)에 근소한 차로 우위](https://www.hani.co.kr/arti/politics/assembly/278356.html)
- 제19대 (2012년) 이재오 vs 천호선
- ["이재오 살리고 MB심판 하자고?", 서울 은평을, 새누리 이재오 vs 통합진보 천호선](https://www.pressian.com/pages/articles/63595)
- 제19대 (2012년) 문재인 vs 손수조
- [부산 사상 손수조·문재인](https://m.khan.co.kr/politics/election/article/201204082255145#c2b)
- 제20대 (2016년) 안철수 vs 이준석
- ['노원 목장'의 결투? 안철수-이준석, 총선 전운](https://www.asiae.co.kr/article/2023031010175976658)
- 제20대 (2016년) 정세균 vs 오세훈
- [정세균 對 오세훈 ‘종로 혈투’…국민의 선택은?](http://sisa-news.com/news/article.html?no=103290)
- 제21대 (2020년) 이낙연 vs 황교안
- [이낙연-황교안, 정치1번지 종로서 맞붙는다](https://www.ccnnews.co.kr/news/articleView.html?idxno=170838)
- 제21대 (2020년) 김용민 vs 주광덕
- [남양주병… '조국 대전' 이슈로 격돌](https://www.yna.co.kr/view/AKR20200313115600060)


```{r}
library(tidyverse)
tribble(~"선거", ~"선거구", ~"유권자", ~"투표수", ~"계", ~"정당", ~"후보", ~"득표수",
"제18대", "동작을", "154,470", "87,793", "87,332", "민주당", "정동영", "36,251",
"제18대", "동작을", "154,470", "87,793", "87,332", "국민의힘", "정몽준", "47,521",
"제18대", "노원병", "158,354", "80,732", "80,170 ", "민주당", "김성환", "13,036 ",
"제18대", "노원병", "158,354", "80,732", "80,170 ", "국민의힘", "홍정욱", "34,554",
"제18대", "노원병", "158,354", "80,732", "80,170 ", "정의당", "노회찬", "32,111",
"제20대", "노원병", "159,717", "103,710", "103,054", "국민의힘", "이준석", "32,285",
"제20대", "노원병", "159,717", "103,710", "103,054", "국민의당", "안철수", "53,930",
"제21대", "종로구", "134,516", "95,239", "94,038", "민주당", "이낙연", "54,902",
"제21대", "종로구", "134,516", "95,239", "94,038", "국민의당", "황교안", "37,594"
)
```



Binary file modified images/당원수_시도별_양당.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/당원수_양당.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions proportion_member.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: "지도제작 대회"
subtitle: "비례국회의원"
description: |
비례국회의원에 대해서 살펴보자.
author:
- name: 이광춘
url: https://www.linkedin.com/in/kwangchunlee/
affiliation: 한국 R 사용자회
affiliation-url: https://github.com/bit2r
title-block-banner: true
format:
html:
theme: flatly
code-fold: true
code-overflow: wrap
toc: true
toc-depth: 3
toc-title: 목차
number-sections: true
highlight-style: github
self-contained: false
default-image-extension: jpg
filters:
- lightbox
lightbox: auto
link-citations: true
knitr:
opts_chunk:
eval: true
message: false
warning: false
collapse: true
comment: "#>"
R.options:
knitr.graphics.auto_pdf: true
editor_options:
chunk_output_type: console
---

```{r}
#| include: false
library(tidyverse)
library(rvest)
library(httr)
library(sf)
library(geogrid)
```


# 데이터셋

```{r}
#| eval: true
library(tidyverse)
library(rvest)
library(httr)
library(sf)
library(geogrid)
mp_raw <- read_rds("data/total_elected_tbl.rds")
prop_tbl <- mp_raw |>
filter(sgTypecode == "7") |>
select(result) |>
unnest(result) |>
mutate(정당 = case_when(jdName %in% c("한나라당", "새누리당", "자유한국당",
"미래통합당", "국민의힘", "미래한국당") ~ "국민의힘",
jdName %in% c("새정치국민회의", "열린우리당", "통합민주당",
"민주통합당", "더불어민주당", "더불어시민당") ~ "민주당",
TRUE ~ "그외정당")) |>
count(sgId, 정당)
```


# 분석

##

```{r}
library(gt)
prop_tbl |>
pivot_wider(names_from = 정당, values_from = n) |>
mutate(소계 = 국민의힘 + 그외정당 + 민주당) |>
select(선거=sgId, 민주당, 국민의힘, 그외정당, 소계) |>
gt() |>
grand_summary_rows(
columns = c(민주당, 국민의힘, 그외정당),
fns = list(
최소 ~ min(.),
최대 ~ max(.),
평균 ~ mean(.)
),
fmt = ~ fmt_integer(.),
side = "top"
) |>
cols_align(columns = everything(), "center")
```

## 그래프

```{r}
percent_tbl <- prop_tbl |>
group_by(sgId) |>
summarise(비율 = n / sum(n)) |>
ungroup()
prop_tbl |>
bind_cols(percent_tbl |> select(비율)) |>
ggplot(aes(x = sgId, y = 비율, color = 정당, group = 정당)) +
geom_line() +
geom_point() +
scale_color_manual(values = c("국민의힘" = "red",
"민주당" = "blue",
"그외정당" = "gray30")) +
scale_y_continuous(labels = scales::percent) +
theme_minimal() +
theme(legend.position = "top")
```


0 comments on commit c463a09

Please sign in to comment.