Skip to content

Instantly share code, notes, and snippets.

@kzktmr
kzktmr / Starbucks_saga.csv
Last active May 17, 2023 04:02
佐賀県内のスターバックス店舗
shop address
佐賀南バイパス店 佐賀県佐賀市本庄町袋306-6
佐賀大学通り店 佐賀県佐賀市与賀町70-1
鳥栖プレミアム・アウトレット店 佐賀県鳥栖市弥生が丘8-1
TSUTAYA鳥栖店 佐賀県鳥栖市本鳥栖町537-1
鳥栖蔵上町店 佐賀県鳥栖市蔵上町662-5
基山パーキングエリア(上り線)店 佐賀県三養基郡基山町小倉2097-1
蔦屋書店武雄市図書館店 佐賀県武雄市武雄町武雄5304-1
佐賀武雄店 佐賀県武雄市武雄町昭和277
唐津店 佐賀県唐津市和多田西山1-46-1
@kzktmr
kzktmr / ggradar.R
Created April 4, 2019 05:13
Draw a radar chart with ggplot.
library(tidyverse)
# http://www.cmap.polytechnique.fr/~lepennec/R/Radar/RadarAndParallelPlots.html
coord_radar <- function (theta = "x", start = 0, direction = 1){
theta <- match.arg(theta, c("x", "y"))
r <- if (theta == "x")
"y"
else "x"
ggproto("CordRadar", CoordPolar, theta = theta, r = r, start = start,
direction = sign(direction),
@kzktmr
kzktmr / 税関符号.csv
Last active May 25, 2018 01:50
税関符号表:外国貿易等に関する統計基本通達( http://www.customs.go.jp/toukei/sankou/dgorder/TU-S59k1048.pdf )別表第2
符号 事務所名
1000 東京税関(本関)
1001 東京税関東京外郵出張所
1005 東京税関立川出張所
1006 東京税関前橋出張所
1007 東京税関大井出張所
1012 東京税関東京航空貨物出張所
1030 東京税関羽田税関支署
1040 東京税関成田航空貨物出張所
1041 成田税関支署
@kzktmr
kzktmr / veterinary_migration.csv
Last active June 24, 2017 15:17
獣医系大学の入学率と就職率との関係について(http://www.kantei.go.jp/jp/singi/tiiki/kokusentoc_wg/hearing_s/140819siryou05_1.pdf
地域性 大学名 自県内入学率 自地域内入学率 自県内就職率 自地域内就職率 出身県への就職率 出身地域への就職率
地方型 帯広 15.2 23.2 29.1 32.6 22.7 34.8
地方型 岩手 13.9 36.1 6 15 26.1 35.2
地方型 鳥取 6.8 30.6 6.7 26.7 29.3 40.7
地方型 山口 9.9 27.3 13.5 20.6 23.8 41.3
地方型 宮崎 13.4 42.5 18.9 41.5 25.5 49.1
地方型 鹿児島 16.7 44.7 25.8 49.2 28.8 52.3
地方型 酪農 21.9 26.5 23.6 26.9 32.2 32.2
地方型 北里 0.5 6.9 3.5 9.2 39.2 61.8
都市型 北海道 7.3 11.3 23.3 25.8 12.9 26.5
@kzktmr
kzktmr / write_excel_mac_csv.R
Created December 27, 2016 14:45
Export csv file that can be opened by Excel for Mac.
write_excel_mac_csv <- function(x, path, na = "NA"){
tmp <- tempfile()
readr::write_tsv(x, tmp, na = na)
path <- paste0("'", path, "'")
system(paste("(printf '\xff\xfe'; iconv -f utf-8 -t utf-16le", tmp, ") >", path))
}
@kzktmr
kzktmr / ggJapanPrefecturesMap.R
Last active December 4, 2016 14:52
Draw a very simple prefectural choropleth map of Japan with ggplot
ggJapanPrefecturesMap <- function (col = "white", fill = NULL, inset = TRUE, silent = FALSE, ...)
{
require(Nippon)
if(require(ggplot2)){
require(foreign)
m <- readShapePoly(system.file("shapes/jpn.shp", package = "Nippon")[1],
proj4string = CRS("+proj=longlat +datum=WGS84"))
if (inset) {
xy.okinawa <- m@polygons[[47]]@Polygons[[1]]@coords
xy.okinawa[, 1] <- xy.okinawa[, 1] + 7
@kzktmr
kzktmr / googleChartJapanMap.R
Last active December 11, 2015 14:30
Draw choropleth map of Japan using (deprecated) Google Chart API from R
# This function uses an old API. It is not recommended to use this function.
googleChartJapanMap <- function(x, width=500, height=600, col.def="gray", col.min="lightgreen", col.max="darkgreen", col.bg="white", file=NULL, title=NULL){
#2010/12/28 ver.0.1 by kzktmr
#2015/12/11 ver.0.2 by kzktmr
stopifnot(length(x)==47, width*height<=300000)
col2hex <- function(col){
col.rgb <- col2rgb(col)
return(substring(rgb(col.rgb[1], col.rgb[2], col.rgb[3], maxColorValue=255), 2))
}
xx <- x[!is.na(x)]
@kzktmr
kzktmr / barplot3d.R
Last active May 16, 2016 23:29
Draw 3D barplot using rgl
require(rgl)
binplot.3d <- function(x, y, z, alpha=1, topcol="#ff0000", sidecol="#aaaaaa", linecol="#000000")
{
save <- par3d(skipRedraw=TRUE)
on.exit(par3d(save))
x1 <- c(rep(c(x[1], x[2], x[2], x[1]), 3), rep(x[1], 4), rep(x[2], 4))
z1 <- c(rep(0, 4), rep(c(0, 0, z, z), 4))
y1 <- c(y[1], y[1], y[2], y[2], rep(y[1], 4), rep(y[2], 4), rep(c(y[1], y[2], y[2], y[1]), 2))
x2 <- c(rep(c(x[1], x[1], x[2], x[2]), 2), rep(c(x[1], x[2], rep(x[1], 3), rep(x[2], 3)), 2))