Skip to content

Instantly share code, notes, and snippets.

View uribo's full-sized avatar
🍉
fine

Shinya Uryu uribo

🍉
fine
View GitHub Profile
@uribo
uribo / vis_tide_level.R
Last active October 7, 2021 21:43
複数地点の潮位データをプロット
library(dplyr)
library(jmastats)
library(ggplot2)
library(ggforce)
# 対象地点のデータを取得 -------------------------------------------------------------
# 東京
df_tk <-
read_tide_level(.year = 2020, .month = 8, .stn = "TK")
@uribo
uribo / read_senkyo_s_shikuchouson.R
Last active August 24, 2021 03:34
衆議院議員総選挙のデータを扱う関数
# 市区町村別得票数
read_senkyo_s_shikuchouson <- function(path, sheet = 1) {
df_raw <-
readxl::read_excel(path,
sheet = sheet,
skip = 3)
df_raw <-
df_raw %>%
dplyr::filter(!is.na(`候補者名`))
x_candidate <-
@uribo
uribo / jma_normal_phenology.R
Created March 31, 2021 14:47
生物季節観測 さくらの開花日・満開日の期間
####################################
# 月*100+日
# 9月5日 --> 905
####################################
library(readr)
library(dplyr)
library(ggplot2)
library(ggalt)
d <-
read_csv("~/Downloads/normal_phenology/nml_phenology.csv",
@uribo
uribo / electric_usage_calendar.R
Created March 25, 2021 13:36
電力使用率をmoon chartsで表現する🌖⚡️
library(dplyr)
library(readr)
library(ggplot2)
library(gggibbous)
library(ggtext)
d <-
read_csv("https://www.tepco.co.jp/forecast/html/images/juyo-result-j.csv",
skip = 2,
locale = locale(encoding = "cp932"))
@uribo
uribo / zipangu210201.R
Last active February 2, 2021 00:26
zipangu v0.2.2
####################################
# zipangu v0.2.2
####################################
library(zipangu)
library(ggplot2)
library(patchwork)
theme_set(theme_bw(base_family = suryulib::jpfont(), base_size = 6))
# ベクトル化 -------------------------------------------------------------------
convert_jdate(c("令和3年2月1日", "令和元年5月1日", "平31年4月1日"))
@uribo
uribo / jma_record_temp.R
Last active August 25, 2020 13:03
気象庁 観測史上の記録
####################################
# 気象庁 観測史上の記録
####################################
library(tidyverse)
library(jmastats) # remotes::install_gitlab("uribo/jmastats")
library(ggalt)
library(sf)
library(patchwork)
tgt_st_block_no <- c("47418", "47407", "47412", "47575", "47582", "47590", "47615", "47662",
library(dplyr)
library(jmastats)
library(ggplot2)
source("https://raw.githubusercontent.com/uribo/japan-heatstroke/master/R/read_moe_wbgt.R")
wbgt_list1 <-
c(l1_lv5 = "#ff2800",
l1_lv4 = "#ff9600",
l1_lv3 = "#faf500",
l1_lv2 = "#a0d2ff",
@uribo
uribo / Transport_flowmap.R
Created July 17, 2020 09:52
Transport census flowmap
###################################
# 大都市交通センサス
# 第12回 首都圏 https://www.mlit.go.jp/sogoseisaku/transport/sosei_transport_tk_000007.html
# 線別駅間移動人員,
# 鉄道位置データ: 国土数値情報 鉄道時系列 https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N05-v1_3.html
# 行政区画: 地球地図日本 https://www.gsi.go.jp/kankyochiri/globalmap.html
# 加工・編集者: 瓜生真也 (Shinya Uryu)
#
# mapboxよりアクセストークンを取得してください
###################################
@uribo
uribo / image_facet_mapping.R
Created March 5, 2020 01:21
imagerで異なる画像を読み込んでggplot2::facet_wrap()で表示する
library(imager)
library(ggplot2)
image_to_rgbdf <- function(file) {
imager::load.image(file) %>%
as.data.frame(wide = "c") %>%
dplyr::mutate(rgb_val = rgb(c.1, c.2, c.3))
}
df_plot <-
@uribo
uribo / dl_stat_data_mesharea.R
Last active January 20, 2020 01:22
tidyestat series
dl_stat_data_mesharea <- function(tbl_code, meshcode, exdir = ".", dest = TRUE) {
x <-
glue::glue("https://www.e-stat.go.jp/gis/statmap-search/data?statsId={tbl_code}&code={meshcode}&downloadType=2")
destfile <-
glue::glue(
"{exdir}/tbl{tbl_code}H{meshcode}.zip")
utils::download.file(url = x,
destfile = destfile)
if (dest == TRUE)
utils::unzip(