library(tidyverse)
library(FactoMineR)
library(factoextra)
得票データは、仙台市選挙管理委員会Webより取得
開票確定数報告
.d <- read_delim("sendai20170723.txt",delim="\t")
## Warning: Missing column names filled in: 'X1' [1]
## Parsed with column specification:
## cols(
## X1 = col_character(),
## `林 ひろき` = col_number(),
## `郡 和子` = col_number(),
## `菅原 ひろのり` = col_number(),
## `大久保 みよ` = col_number()
## )
.d.df <- as.data.frame(.d)
rownames(.d.df) <- .d$X1
.d.tbl <- .d.df[,2:5]
.d.tbl %>% summarise_all(.funs = sum) %>% rbind(.d.tbl,合計=.) -> .d.tbl.margin
knitr::kable(t(.d.tbl.margin))
| 青葉区 | 宮城野区 | 若林区 | 太白区 | 泉区 | 合計 | |
|---|---|---|---|---|---|---|
| 林 ひろき | 17040 | 9820 | 7995 | 13408 | 13384 | 61647 |
| 郡 和子 | 46163 | 25549 | 19765 | 38786 | 35189 | 165452 |
| 菅原 ひろのり | 42613 | 25598 | 18059 | 29466 | 33257 | 148993 |
| 大久保 みよ | 2588 | 1538 | 1083 | 1801 | 1914 | 8924 |
.tbl <- margin.table(t(.d.tbl),1)
pie(.tbl,clockwise = TRUE)
mosaicplot(t(.d.tbl),main="20170723 候補者",shade = TRUE)
mosaicplot(.d.tbl,main="20170723 地区",shade = TRUE)
res.CA <- CA(.d.tbl,graph=FALSE)
fviz_ca(res.CA,font.family = "sans")