1. 武内候補の得票率

d1 <- c(14,30,61,110,117,100,127,62) # パーセントの基数
d2 <- c(3,11,36,51,62,44,47,20)
d3 <- d1 - d2
round(d2/d1*100,digits = 1)
## [1] 21.4 36.7 59.0 46.4 53.0 44.0 37.0 32.3
d2 # 武内得票数
## [1]  3 11 36 51 62 44 47 20
d3 # その他候補得票数
## [1] 11 19 25 59 55 56 80 42
m <- matrix(c(d2,d3),nrow = 8)
m
##      [,1] [,2]
## [1,]    3   11
## [2,]   11   19
## [3,]   36   25
## [4,]   51   59
## [5,]   62   55
## [6,]   44   56
## [7,]   47   80
## [8,]   20   42
dimnames(m) <- list(
  Age = c("18-19","20s","30s","40s","50s","60s","70s","80-"),
  Candidate = c("Takeuchi","Others")
)

m
##        Candidate
## Age     Takeuchi Others
##   18-19        3     11
##   20s         11     19
##   30s         36     25
##   40s         51     59
##   50s         62     55
##   60s         44     56
##   70s         47     80
##   80-         20     42
# 行列の保存
m82 <- m

モザイク図(1)

mosaicplot(m,color = T,main = "")

モザイク図(2)

par(family= "HiraKakuProN-W3", cex=0.86) 
mosaicplot(m,shade=TRUE, main = "",dir=c("h","v"))