Skip to content

Instantly share code, notes, and snippets.

View uribo's full-sized avatar
🍉
fine

Shinya Uryu uribo

🍉
fine
View GitHub Profile
library(httr2)
library(rvest)
# ページリスト ------------------------------------------------------------------
req <-
request("https://scrapbox.io/") |>
req_url_path_append("api/pages/") |>
req_url_path_append("mandaRa")
x <-
req |>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@uribo
uribo / estat_toukei_00500215.R
Created February 23, 2023 07:53
作物統計調査のデータをダウンロードして綺麗な形でRに読み込む
##############################
# 作物統計調査のデータをダウンロードして綺麗な形でRに読み込む
# 表分類: 品目別結果樹面積、収穫量及び出荷量累年統計(昭和48年~)
##############################
# 1. 対象のデータを一覧にする ---------------------------------------------------------
base_url <- "https://www.e-stat.go.jp"
df_item <-
seq.int(2) |>
purrr::map(
@uribo
uribo / URL
Last active December 8, 2022 01:29
https://mybinder.org/v2/gh/uribo/binder221202/main?urlpath=git-pull?repo=https://github.com/uribo/cue2022aw_r104
@uribo
uribo / zip_to_administration.R
Last active September 28, 2022 04:32
郵便番号から該当する都道府県・市区町村・町域名、jis codeを検索
read_zipcode_oogaki <-
memoise::memoise(
function(.path) {
dplyr::select(zipangu::read_zipcode(.path,
type = "oogaki"),
jis_code, zip_code, prefecture, city, street)
}
)
zip_to_administration <- function(x, value = "jis_code", .path = NULL) {
apple_book_name_fix <- function(data) {
purrr::set_names(data,
stringr::str_to_lower(
stringr::str_remove(names(data), "^Z")
))
}
apple_book_markers <- function() {
con <- DBI::dbConnect(RSQLite::SQLite(),
"~/Library/Containers/com.apple.iBooksX/Data/Documents/AEAnnotation/AEAnnotation_v10312011_1727_local.sqlite",
@uribo
uribo / hadley_ds_cycle.R
Last active January 12, 2022 04:51
Hadley Wickham's Data Science Cycle with R
library(DiagrammeR)
library(remoji)
nodes <-
create_nodes(
nodes = c(
paste0(emoji("floppy_disk"), "Import"),
paste0(emoji("repeat"), "Tidy"),
paste(
paste0(
@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 / maff_disaster1964-2020.R
Last active August 27, 2021 03:09
農林水産省 過去の主な異常災害等と農林水産被害
######################################
# 農林水産省 過去の主な異常災害等と農林水産被害
# http://www.maff.go.jp/j/saigai/arc/index-1.html
######################################
# 1/3 Setup -------------------------------------------------------------------
library(dplyr)
library(purrr)
library(stringr)
bind_line2df <- function(x, index) {
x[index] %>%
@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 <-