Last active
January 29, 2023 02:34
-
-
Save ito4303/f628e12f0c2a13f3a974e3f097879916 to your computer and use it in GitHub Desktop.
Draw Keikenti map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 経県値マップ*1をプロットするRスクリプト | |
# *1 https://uub.jp/j.cgi/ | |
library(NipponMap) | |
library(stringr) | |
col_map <- c("white", "cyan", "yellowgreen", "yellow", "red", "purple") | |
# MAPの値は、都道府県コードの順にスコアを並べたものになります。 | |
MAP <- "54443245434454445444444445444444444444441443444" | |
if (str_length(MAP) != 47) { | |
stop("MAP文字列の長さがちがいます。") | |
} else { | |
num_map <- sapply(1:47, | |
function(i) { | |
as.numeric(str_sub(MAP, i, i)) | |
}) | |
keikenti <- sum(num_map) | |
JapanPrefMap(col = col_map[num_map + 1]) | |
print(keikenti) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment