SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
> me
$name
[1] "Takashi Kitano"
$twitter
[1] "@kashitan"
$work_in
[1] " " %>% " "




glimpse(choices)
List of 4
$ : Named chr [1:58] "11101" "11102" "11103" "11104" ...
..- attr(*, "names")= chr [1:58] " " " " "
" " " ...
$ : Named chr [1:36] "12101" "12102" "12103" "12104" ...
..- attr(*, "names")= chr [1:36] " " " " "
" " " ...
$ : Named chr [1:51] "13101" "13102" "13103" "13104" ...
..- attr(*, "names")= chr [1:51] " " " " " " "
" ...
names(choices)
[1] " " " " " " " "
choices[[" "]]
"13101" "13102" "13103" "13104" "13105" "13106"
"13107" "13108" "13109"
"13110" "13111" "13112" "13113" "13114" "13115"
"13116" "13117" "13118"
selectInput(
inputId = "pref",
label = " ",
choices = names(choices),
selected = " ",
width = "100%"
)
selectInput(
inputId = "city",
label = " ",
#
choices = choices$` `,
selected = "13112",
width = "100%"
)
server <- function(input, output, session) {
observe({
city_choices <- choices[[input$pref]]
city <- input$city
#
#
if (!(city %in% city_choices)) {
city <- city_choices[1]
}
updateSelectInput(
session, inputId = “city",
choices = city_choices, selected = city
)
})
}
#
tags$style(type = "text/css", "#map {height: calc(90vh - 80px) !
important;}"),
leafletOutput("map")
output$map <- leaflet::renderLeaflet({
leaflet::leaflet() %>%
leaflet::addProviderTiles(providers$CartoDB.Positron)
})
observe({
pal <-
leaflet::colorNumeric("Spectral", dat.sub()$n, reverse = TRUE)
map <- leaflet::leafletProxy("map", data = dat.sub()) %>%
leaflet::clearShapes() %>%
leaflet::clearControls() %>%
leaflet::addPolygons(fillColor = ~ pal(n), color = "gray",
popup = ~ NAME, weight = 1,
fillOpacity = 0.8) %>%
leaflet::addLegend("bottomright", pal = pal, values = ~ n,
title = "Population", opacity = 1)
map
})
observe({
pal <-
leaflet::colorNumeric("Spectral", dat.sub()$n, reverse = TRUE)
map <- leaflet::leafletProxy("map", data = dat.sub()) %>%
leaflet::clearShapes() %>%
leaflet::clearControls() %>%
leaflet::addPolygons(fillColor = ~ pal(n), color = "gray",
popup = ~ NAME, weight = 1,
fillOpacity = 0.8) %>%
leaflet::addLegend("bottomright", pal = pal, values = ~ n,
title = "Population", opacity = 1)
map
})
is.fitBounds <- FALSE
observeEvent(input$city, {
is.fitBounds <<- TRUE
})
observe({
if (is.fitBounds) {
#
bbox <- dat.sub() %>%
sf::st_bbox()
names(bbox) <- NULL
map <- map %>%
leaflet::fitBounds(bbox[1], bbox[2], bbox[3], bbox[4])
is.fitBounds <<- FALSE
}
map
is.fitBounds <- FALSE
observeEvent(input$city, {
is.fitBounds <<- TRUE
})
observe({
if (is.fitBounds) {
#
bbox <- dat.sub() %>%
sf::st_bbox()
names(bbox) <- NULL
map <- map %>%
leaflet::fitBounds(bbox[1], bbox[2], bbox[3], bbox[4])
is.fitBounds <<- FALSE
}
map
observeEvent(input$map_shape_click, {
p <- input$map_shape_click
#
shp.sub <- shp[[input$pref]] %>%
dplyr::filter(stringr::str_sub(KEY_CODE, 1, 5) %in%
choices[[input$pref]])
#
ind <- sf::st_point(c(p$lng, p$lat), dim = "XY") %>%
sf::st_within(shp.sub) %>% unlist()
})
observeEvent(input$map_shape_click, {
p <- input$map_shape_click
#
shp.sub <- shp[[input$pref]] %>%
dplyr::filter(stringr::str_sub(KEY_CODE, 1, 5) %in%
choices[[input$pref]])
#
ind <- sf::st_point(c(p$lng, p$lat), dim = "XY") %>%
sf::st_within(shp.sub) %>% unlist()
})
{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips

Contenu connexe

Tendances

SIX ABEJA 講演資料 もうブラックボックスとは呼ばせない~機械学習を支援する情報
SIX ABEJA 講演資料 もうブラックボックスとは呼ばせない~機械学習を支援する情報SIX ABEJA 講演資料 もうブラックボックスとは呼ばせない~機械学習を支援する情報
SIX ABEJA 講演資料 もうブラックボックスとは呼ばせない~機械学習を支援する情報Takayuki Itoh
 
Rubinの論文(の行間)を読んでみる-傾向スコアの理論-
Rubinの論文(の行間)を読んでみる-傾向スコアの理論-Rubinの論文(の行間)を読んでみる-傾向スコアの理論-
Rubinの論文(の行間)を読んでみる-傾向スコアの理論-Koichiro Gibo
 
変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)Takao Yamanaka
 
合成変量とアンサンブル:回帰森と加法モデルの要点
合成変量とアンサンブル:回帰森と加法モデルの要点合成変量とアンサンブル:回帰森と加法モデルの要点
合成変量とアンサンブル:回帰森と加法モデルの要点Ichigaku Takigawa
 
Chapter9 一歩進んだ文法(前半)
Chapter9 一歩進んだ文法(前半)Chapter9 一歩進んだ文法(前半)
Chapter9 一歩進んだ文法(前半)itoyan110
 
Rでソーシャルネットワーク分析
Rでソーシャルネットワーク分析Rでソーシャルネットワーク分析
Rでソーシャルネットワーク分析Hiroko Onari
 
質的変数の相関・因子分析
質的変数の相関・因子分析質的変数の相関・因子分析
質的変数の相関・因子分析Mitsuo Shimohata
 
クラスタ数の決め方(Tokyo.r#60)
クラスタ数の決め方(Tokyo.r#60)クラスタ数の決め方(Tokyo.r#60)
クラスタ数の決め方(Tokyo.r#60)osamu morimoto
 
15分でわかる(範囲の)ベイズ統計学
15分でわかる(範囲の)ベイズ統計学15分でわかる(範囲の)ベイズ統計学
15分でわかる(範囲の)ベイズ統計学Ken'ichi Matsui
 
統計的学習の基礎_3章
統計的学習の基礎_3章統計的学習の基礎_3章
統計的学習の基礎_3章Shoichi Taguchi
 
クラシックな機械学習の入門  11.評価方法
クラシックな機械学習の入門  11.評価方法クラシックな機械学習の入門  11.評価方法
クラシックな機械学習の入門  11.評価方法Hiroshi Nakagawa
 
距離とクラスタリング
距離とクラスタリング距離とクラスタリング
距離とクラスタリング大貴 末廣
 
Cmdstanr入門とreduce_sum()解説
Cmdstanr入門とreduce_sum()解説Cmdstanr入門とreduce_sum()解説
Cmdstanr入門とreduce_sum()解説Hiroshi Shimizu
 
TokyoR101_BeginnersSession2.pdf
TokyoR101_BeginnersSession2.pdfTokyoR101_BeginnersSession2.pdf
TokyoR101_BeginnersSession2.pdfkotora_0507
 
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)Yoshitake Takebayashi
 
パターン認識と機械学習入門
パターン認識と機械学習入門パターン認識と機械学習入門
パターン認識と機械学習入門Momoko Hayamizu
 
ディリクレ過程に基づく無限混合線形回帰モデル in 機械学習プロフェッショナルシリーズ輪読会
ディリクレ過程に基づく無限混合線形回帰モデル in 機械学習プロフェッショナルシリーズ輪読会ディリクレ過程に基づく無限混合線形回帰モデル in 機械学習プロフェッショナルシリーズ輪読会
ディリクレ過程に基づく無限混合線形回帰モデル in 機械学習プロフェッショナルシリーズ輪読会Shotaro Sano
 
バンディットアルゴリズム入門と実践
バンディットアルゴリズム入門と実践バンディットアルゴリズム入門と実践
バンディットアルゴリズム入門と実践智之 村上
 
StanとRでベイズ統計モデリング読書会(Osaka.stan) 第6章
StanとRでベイズ統計モデリング読書会(Osaka.stan) 第6章StanとRでベイズ統計モデリング読書会(Osaka.stan) 第6章
StanとRでベイズ統計モデリング読書会(Osaka.stan) 第6章Shushi Namba
 

Tendances (20)

SIX ABEJA 講演資料 もうブラックボックスとは呼ばせない~機械学習を支援する情報
SIX ABEJA 講演資料 もうブラックボックスとは呼ばせない~機械学習を支援する情報SIX ABEJA 講演資料 もうブラックボックスとは呼ばせない~機械学習を支援する情報
SIX ABEJA 講演資料 もうブラックボックスとは呼ばせない~機械学習を支援する情報
 
Rubinの論文(の行間)を読んでみる-傾向スコアの理論-
Rubinの論文(の行間)を読んでみる-傾向スコアの理論-Rubinの論文(の行間)を読んでみる-傾向スコアの理論-
Rubinの論文(の行間)を読んでみる-傾向スコアの理論-
 
変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)変分推論法(変分ベイズ法)(PRML第10章)
変分推論法(変分ベイズ法)(PRML第10章)
 
合成変量とアンサンブル:回帰森と加法モデルの要点
合成変量とアンサンブル:回帰森と加法モデルの要点合成変量とアンサンブル:回帰森と加法モデルの要点
合成変量とアンサンブル:回帰森と加法モデルの要点
 
Chapter9 一歩進んだ文法(前半)
Chapter9 一歩進んだ文法(前半)Chapter9 一歩進んだ文法(前半)
Chapter9 一歩進んだ文法(前半)
 
Rでソーシャルネットワーク分析
Rでソーシャルネットワーク分析Rでソーシャルネットワーク分析
Rでソーシャルネットワーク分析
 
質的変数の相関・因子分析
質的変数の相関・因子分析質的変数の相関・因子分析
質的変数の相関・因子分析
 
Gephi Tutorial Visualization (Japanese)
Gephi Tutorial Visualization (Japanese)Gephi Tutorial Visualization (Japanese)
Gephi Tutorial Visualization (Japanese)
 
クラスタ数の決め方(Tokyo.r#60)
クラスタ数の決め方(Tokyo.r#60)クラスタ数の決め方(Tokyo.r#60)
クラスタ数の決め方(Tokyo.r#60)
 
15分でわかる(範囲の)ベイズ統計学
15分でわかる(範囲の)ベイズ統計学15分でわかる(範囲の)ベイズ統計学
15分でわかる(範囲の)ベイズ統計学
 
統計的学習の基礎_3章
統計的学習の基礎_3章統計的学習の基礎_3章
統計的学習の基礎_3章
 
クラシックな機械学習の入門  11.評価方法
クラシックな機械学習の入門  11.評価方法クラシックな機械学習の入門  11.評価方法
クラシックな機械学習の入門  11.評価方法
 
距離とクラスタリング
距離とクラスタリング距離とクラスタリング
距離とクラスタリング
 
Cmdstanr入門とreduce_sum()解説
Cmdstanr入門とreduce_sum()解説Cmdstanr入門とreduce_sum()解説
Cmdstanr入門とreduce_sum()解説
 
TokyoR101_BeginnersSession2.pdf
TokyoR101_BeginnersSession2.pdfTokyoR101_BeginnersSession2.pdf
TokyoR101_BeginnersSession2.pdf
 
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
マルコフ連鎖モンテカルロ法 (2/3はベイズ推定の話)
 
パターン認識と機械学習入門
パターン認識と機械学習入門パターン認識と機械学習入門
パターン認識と機械学習入門
 
ディリクレ過程に基づく無限混合線形回帰モデル in 機械学習プロフェッショナルシリーズ輪読会
ディリクレ過程に基づく無限混合線形回帰モデル in 機械学習プロフェッショナルシリーズ輪読会ディリクレ過程に基づく無限混合線形回帰モデル in 機械学習プロフェッショナルシリーズ輪読会
ディリクレ過程に基づく無限混合線形回帰モデル in 機械学習プロフェッショナルシリーズ輪読会
 
バンディットアルゴリズム入門と実践
バンディットアルゴリズム入門と実践バンディットアルゴリズム入門と実践
バンディットアルゴリズム入門と実践
 
StanとRでベイズ統計モデリング読書会(Osaka.stan) 第6章
StanとRでベイズ統計モデリング読書会(Osaka.stan) 第6章StanとRでベイズ統計モデリング読書会(Osaka.stan) 第6章
StanとRでベイズ統計モデリング読書会(Osaka.stan) 第6章
 

Similaire à {shiny}と{leaflet}による地図アプリ開発Tips

JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...PROIDEA
 
An example of R code for Data visualization
An example of R code for Data visualizationAn example of R code for Data visualization
An example of R code for Data visualizationLiang (Leon) Zhou
 
[1062BPY12001] Data analysis with R / week 4
[1062BPY12001] Data analysis with R / week 4[1062BPY12001] Data analysis with R / week 4
[1062BPY12001] Data analysis with R / week 4Kevin Chun-Hsien Hsu
 
BOXPLOT EXAMPLES in R And An Example for BEESWARM:
BOXPLOT EXAMPLES in R And  An Example for BEESWARM:BOXPLOT EXAMPLES in R And  An Example for BEESWARM:
BOXPLOT EXAMPLES in R And An Example for BEESWARM:Dr. Volkan OBAN
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collectionsMyeongin Woo
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)riue
 
Modern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter BootstrapModern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter BootstrapHoward Lewis Ship
 
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
Implement the following sorting algorithms  Bubble Sort  Insertion S.pdfImplement the following sorting algorithms  Bubble Sort  Insertion S.pdf
Implement the following sorting algorithms Bubble Sort Insertion S.pdfkesav24
 
GenStage and Flow - Jose Valim
GenStage and Flow - Jose Valim GenStage and Flow - Jose Valim
GenStage and Flow - Jose Valim Elixir Club
 
Some Examples in R- [Data Visualization--R graphics]
 Some Examples in R- [Data Visualization--R graphics] Some Examples in R- [Data Visualization--R graphics]
Some Examples in R- [Data Visualization--R graphics]Dr. Volkan OBAN
 
Python Collection datatypes
Python Collection datatypesPython Collection datatypes
Python Collection datatypesAdheetha O. V
 
Артём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisАртём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisSpbDotNet Community
 

Similaire à {shiny}と{leaflet}による地図アプリ開発Tips (20)

JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
JDD2015: Functional programing and Event Sourcing - a pair made in heaven - e...
 
An example of R code for Data visualization
An example of R code for Data visualizationAn example of R code for Data visualization
An example of R code for Data visualization
 
[1062BPY12001] Data analysis with R / week 4
[1062BPY12001] Data analysis with R / week 4[1062BPY12001] Data analysis with R / week 4
[1062BPY12001] Data analysis with R / week 4
 
R lecture oga
R lecture ogaR lecture oga
R lecture oga
 
Map, Reduce and Filter in Swift
Map, Reduce and Filter in SwiftMap, Reduce and Filter in Swift
Map, Reduce and Filter in Swift
 
purrr.pdf
purrr.pdfpurrr.pdf
purrr.pdf
 
BOXPLOT EXAMPLES in R And An Example for BEESWARM:
BOXPLOT EXAMPLES in R And  An Example for BEESWARM:BOXPLOT EXAMPLES in R And  An Example for BEESWARM:
BOXPLOT EXAMPLES in R And An Example for BEESWARM:
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collections
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
library(sparkline)
library(sparkline)library(sparkline)
library(sparkline)
 
Modern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter BootstrapModern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter Bootstrap
 
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
Implement the following sorting algorithms  Bubble Sort  Insertion S.pdfImplement the following sorting algorithms  Bubble Sort  Insertion S.pdf
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
 
Python Lecture 11
Python Lecture 11Python Lecture 11
Python Lecture 11
 
GenStage and Flow - Jose Valim
GenStage and Flow - Jose Valim GenStage and Flow - Jose Valim
GenStage and Flow - Jose Valim
 
Some Examples in R- [Data Visualization--R graphics]
 Some Examples in R- [Data Visualization--R graphics] Some Examples in R- [Data Visualization--R graphics]
Some Examples in R- [Data Visualization--R graphics]
 
Python Collection datatypes
Python Collection datatypesPython Collection datatypes
Python Collection datatypes
 
Zippers
ZippersZippers
Zippers
 
List out of lambda
List out of lambdaList out of lambda
List out of lambda
 
Артём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisАртём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data Analysis
 

Plus de Takashi Kitano

好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜Takashi Kitano
 
令和から本気出す
令和から本気出す令和から本気出す
令和から本気出すTakashi Kitano
 
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver){tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)Takashi Kitano
 
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析Takashi Kitano
 
20170923 excelユーザーのためのr入門
20170923 excelユーザーのためのr入門20170923 excelユーザーのためのr入門
20170923 excelユーザーのためのr入門Takashi Kitano
 
mxnetで頑張る深層学習
mxnetで頑張る深層学習mxnetで頑張る深層学習
mxnetで頑張る深層学習Takashi Kitano
 
可視化周辺の進化がヤヴァイ 〜2016〜
可視化周辺の進化がヤヴァイ 〜2016〜可視化周辺の進化がヤヴァイ 〜2016〜
可視化周辺の進化がヤヴァイ 〜2016〜Takashi Kitano
 
Rによるウイスキー分析
Rによるウイスキー分析Rによるウイスキー分析
Rによるウイスキー分析Takashi Kitano
 
20160311 基礎からのベイズ統計学輪読会第6章 公開ver
20160311 基礎からのベイズ統計学輪読会第6章 公開ver20160311 基礎からのベイズ統計学輪読会第6章 公開ver
20160311 基礎からのベイズ統計学輪読会第6章 公開verTakashi Kitano
 
20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyor20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyorTakashi Kitano
 
lubridateパッケージ入門
lubridateパッケージ入門lubridateパッケージ入門
lubridateパッケージ入門Takashi Kitano
 
Google's r style guideのすゝめ
Google's r style guideのすゝめGoogle's r style guideのすゝめ
Google's r style guideのすゝめTakashi Kitano
 

Plus de Takashi Kitano (14)

好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
 
令和から本気出す
令和から本気出す令和から本気出す
令和から本気出す
 
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver){tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
 
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
 
20170923 excelユーザーのためのr入門
20170923 excelユーザーのためのr入門20170923 excelユーザーのためのr入門
20170923 excelユーザーのためのr入門
 
mxnetで頑張る深層学習
mxnetで頑張る深層学習mxnetで頑張る深層学習
mxnetで頑張る深層学習
 
可視化周辺の進化がヤヴァイ 〜2016〜
可視化周辺の進化がヤヴァイ 〜2016〜可視化周辺の進化がヤヴァイ 〜2016〜
可視化周辺の進化がヤヴァイ 〜2016〜
 
Rによるウイスキー分析
Rによるウイスキー分析Rによるウイスキー分析
Rによるウイスキー分析
 
20160311 基礎からのベイズ統計学輪読会第6章 公開ver
20160311 基礎からのベイズ統計学輪読会第6章 公開ver20160311 基礎からのベイズ統計学輪読会第6章 公開ver
20160311 基礎からのベイズ統計学輪読会第6章 公開ver
 
20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyor20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyor
 
lubridateパッケージ入門
lubridateパッケージ入門lubridateパッケージ入門
lubridateパッケージ入門
 
20150329 tokyo r47
20150329 tokyo r4720150329 tokyo r47
20150329 tokyo r47
 
20140920 tokyo r43
20140920 tokyo r4320140920 tokyo r43
20140920 tokyo r43
 
Google's r style guideのすゝめ
Google's r style guideのすゝめGoogle's r style guideのすゝめ
Google's r style guideのすゝめ
 

Dernier

Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Seán Kennedy
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesTimothy Spann
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...Boston Institute of Analytics
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...ssuserf63bd7
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024Susanna-Assunta Sansone
 
MK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docxMK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docxUnduhUnggah1
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectBoston Institute of Analytics
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our WorldEduminds Learning
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一F sss
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Colleen Farrelly
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryJeremy Anderson
 
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhh
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhhThiophen Mechanism khhjjjjjjjhhhhhhhhhhh
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhhYasamin16
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfchwongval
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 

Dernier (20)

Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
 
MK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docxMK KOMUNIKASI DATA (TI)komdat komdat.docx
MK KOMUNIKASI DATA (TI)komdat komdat.docx
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis Project
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
Learn How Data Science Changes Our World
Learn How Data Science Changes Our WorldLearn How Data Science Changes Our World
Learn How Data Science Changes Our World
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
办理学位证加利福尼亚大学洛杉矶分校毕业证,UCLA成绩单原版一比一
 
Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024Generative AI for Social Good at Open Data Science East 2024
Generative AI for Social Good at Open Data Science East 2024
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data Story
 
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhh
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhhThiophen Mechanism khhjjjjjjjhhhhhhhhhhh
Thiophen Mechanism khhjjjjjjjhhhhhhhhhhh
 
Multiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdfMultiple time frame trading analysis -brianshannon.pdf
Multiple time frame trading analysis -brianshannon.pdf
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 

{shiny}と{leaflet}による地図アプリ開発Tips

  • 1.
  • 2. > me $name [1] "Takashi Kitano" $twitter [1] "@kashitan" $work_in [1] " " %>% " "
  • 3.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. glimpse(choices) List of 4 $ : Named chr [1:58] "11101" "11102" "11103" "11104" ... ..- attr(*, "names")= chr [1:58] " " " " " " " " ... $ : Named chr [1:36] "12101" "12102" "12103" "12104" ... ..- attr(*, "names")= chr [1:36] " " " " " " " " ... $ : Named chr [1:51] "13101" "13102" "13103" "13104" ... ..- attr(*, "names")= chr [1:51] " " " " " " " " ...
  • 10. names(choices) [1] " " " " " " " " choices[[" "]] "13101" "13102" "13103" "13104" "13105" "13106" "13107" "13108" "13109" "13110" "13111" "13112" "13113" "13114" "13115" "13116" "13117" "13118"
  • 11. selectInput( inputId = "pref", label = " ", choices = names(choices), selected = " ", width = "100%" ) selectInput( inputId = "city", label = " ", # choices = choices$` `, selected = "13112", width = "100%" )
  • 12. server <- function(input, output, session) { observe({ city_choices <- choices[[input$pref]] city <- input$city # # if (!(city %in% city_choices)) { city <- city_choices[1] } updateSelectInput( session, inputId = “city", choices = city_choices, selected = city ) }) }
  • 13.
  • 14.
  • 15.
  • 16. # tags$style(type = "text/css", "#map {height: calc(90vh - 80px) ! important;}"), leafletOutput("map")
  • 17. output$map <- leaflet::renderLeaflet({ leaflet::leaflet() %>% leaflet::addProviderTiles(providers$CartoDB.Positron) })
  • 18. observe({ pal <- leaflet::colorNumeric("Spectral", dat.sub()$n, reverse = TRUE) map <- leaflet::leafletProxy("map", data = dat.sub()) %>% leaflet::clearShapes() %>% leaflet::clearControls() %>% leaflet::addPolygons(fillColor = ~ pal(n), color = "gray", popup = ~ NAME, weight = 1, fillOpacity = 0.8) %>% leaflet::addLegend("bottomright", pal = pal, values = ~ n, title = "Population", opacity = 1) map })
  • 19. observe({ pal <- leaflet::colorNumeric("Spectral", dat.sub()$n, reverse = TRUE) map <- leaflet::leafletProxy("map", data = dat.sub()) %>% leaflet::clearShapes() %>% leaflet::clearControls() %>% leaflet::addPolygons(fillColor = ~ pal(n), color = "gray", popup = ~ NAME, weight = 1, fillOpacity = 0.8) %>% leaflet::addLegend("bottomright", pal = pal, values = ~ n, title = "Population", opacity = 1) map })
  • 20.
  • 21.
  • 22.
  • 23. is.fitBounds <- FALSE observeEvent(input$city, { is.fitBounds <<- TRUE }) observe({ if (is.fitBounds) { # bbox <- dat.sub() %>% sf::st_bbox() names(bbox) <- NULL map <- map %>% leaflet::fitBounds(bbox[1], bbox[2], bbox[3], bbox[4]) is.fitBounds <<- FALSE } map
  • 24. is.fitBounds <- FALSE observeEvent(input$city, { is.fitBounds <<- TRUE }) observe({ if (is.fitBounds) { # bbox <- dat.sub() %>% sf::st_bbox() names(bbox) <- NULL map <- map %>% leaflet::fitBounds(bbox[1], bbox[2], bbox[3], bbox[4]) is.fitBounds <<- FALSE } map
  • 25.
  • 26.
  • 27.
  • 28. observeEvent(input$map_shape_click, { p <- input$map_shape_click # shp.sub <- shp[[input$pref]] %>% dplyr::filter(stringr::str_sub(KEY_CODE, 1, 5) %in% choices[[input$pref]]) # ind <- sf::st_point(c(p$lng, p$lat), dim = "XY") %>% sf::st_within(shp.sub) %>% unlist() })
  • 29. observeEvent(input$map_shape_click, { p <- input$map_shape_click # shp.sub <- shp[[input$pref]] %>% dplyr::filter(stringr::str_sub(KEY_CODE, 1, 5) %in% choices[[input$pref]]) # ind <- sf::st_point(c(p$lng, p$lat), dim = "XY") %>% sf::st_within(shp.sub) %>% unlist() })