SlideShare a Scribd company logo
> 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

More Related Content

What's hot

ggplot2再入門(2015年バージョン)
ggplot2再入門(2015年バージョン)ggplot2再入門(2015年バージョン)
ggplot2再入門(2015年バージョン)
yutannihilation
 
友人関係と感染症伝搬をネットワークで理解する
友人関係と感染症伝搬をネットワークで理解する友人関係と感染症伝搬をネットワークで理解する
友人関係と感染症伝搬をネットワークで理解する
tm1966
 
比例ハザードモデルはとってもtricky!
比例ハザードモデルはとってもtricky!比例ハザードモデルはとってもtricky!
比例ハザードモデルはとってもtricky!takehikoihayashi
 
Rによるベイジアンネットワーク入門
Rによるベイジアンネットワーク入門Rによるベイジアンネットワーク入門
Rによるベイジアンネットワーク入門
Okamoto Laboratory, The University of Electro-Communications
 
ブースティング入門
ブースティング入門ブースティング入門
ブースティング入門
Retrieva inc.
 
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
Ken'ichi Matsui
 
R言語による アソシエーション分析-組合せ・事象の規則を解明する-(第5回R勉強会@東京)
R言語による アソシエーション分析-組合せ・事象の規則を解明する-(第5回R勉強会@東京)R言語による アソシエーション分析-組合せ・事象の規則を解明する-(第5回R勉強会@東京)
R言語による アソシエーション分析-組合せ・事象の規則を解明する-(第5回R勉強会@東京)
Koichi Hamada
 
グラフニューラルネットワーク入門
グラフニューラルネットワーク入門グラフニューラルネットワーク入門
グラフニューラルネットワーク入門
ryosuke-kojima
 
第五回統計学勉強会@東大駒場
第五回統計学勉強会@東大駒場第五回統計学勉強会@東大駒場
第五回統計学勉強会@東大駒場Daisuke Yoneoka
 
画像処理基礎
画像処理基礎画像処理基礎
画像処理基礎
大貴 末廣
 
【読書会資料】『StanとRでベイズ統計モデリング』Chapter12:時間や空間を扱うモデル
【読書会資料】『StanとRでベイズ統計モデリング』Chapter12:時間や空間を扱うモデル【読書会資料】『StanとRでベイズ統計モデリング』Chapter12:時間や空間を扱うモデル
【読書会資料】『StanとRでベイズ統計モデリング』Chapter12:時間や空間を扱うモデル
Masashi Komori
 
機械学習モデルの列挙
機械学習モデルの列挙機械学習モデルの列挙
機械学習モデルの列挙
Satoshi Hara
 
社会心理学者のための時系列分析入門_小森
社会心理学者のための時系列分析入門_小森社会心理学者のための時系列分析入門_小森
社会心理学者のための時系列分析入門_小森
Masashi Komori
 
グラフデータの機械学習における特徴表現の設計と学習
グラフデータの機械学習における特徴表現の設計と学習グラフデータの機械学習における特徴表現の設計と学習
グラフデータの機械学習における特徴表現の設計と学習
Ichigaku Takigawa
 
2部グラフとソーシャルネットワーク
2部グラフとソーシャルネットワーク2部グラフとソーシャルネットワーク
2部グラフとソーシャルネットワーク
Hiroko Onari
 
計量時系列分析の立場からビジネスの現場のデータを見てみよう - 30th Tokyo Webmining
計量時系列分析の立場からビジネスの現場のデータを見てみよう - 30th Tokyo Webmining計量時系列分析の立場からビジネスの現場のデータを見てみよう - 30th Tokyo Webmining
計量時系列分析の立場からビジネスの現場のデータを見てみよう - 30th Tokyo Webmining
Takashi J OZAKI
 
Visual Studio CodeでRを使う
Visual Studio CodeでRを使うVisual Studio CodeでRを使う
Visual Studio CodeでRを使う
Atsushi Hayakawa
 
因果推論を用いた 群衆移動の誘導における介入効果推定
因果推論を用いた 群衆移動の誘導における介入効果推定因果推論を用いた 群衆移動の誘導における介入効果推定
因果推論を用いた 群衆移動の誘導における介入効果推定
Koh Takeuchi
 
グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?
Insight Technology, Inc.
 
ベイジアンネットとレコメンデーション -第5回データマイニング+WEB勉強会@東京
ベイジアンネットとレコメンデーション -第5回データマイニング+WEB勉強会@東京ベイジアンネットとレコメンデーション -第5回データマイニング+WEB勉強会@東京
ベイジアンネットとレコメンデーション -第5回データマイニング+WEB勉強会@東京
Koichi Hamada
 

What's hot (20)

ggplot2再入門(2015年バージョン)
ggplot2再入門(2015年バージョン)ggplot2再入門(2015年バージョン)
ggplot2再入門(2015年バージョン)
 
友人関係と感染症伝搬をネットワークで理解する
友人関係と感染症伝搬をネットワークで理解する友人関係と感染症伝搬をネットワークで理解する
友人関係と感染症伝搬をネットワークで理解する
 
比例ハザードモデルはとってもtricky!
比例ハザードモデルはとってもtricky!比例ハザードモデルはとってもtricky!
比例ハザードモデルはとってもtricky!
 
Rによるベイジアンネットワーク入門
Rによるベイジアンネットワーク入門Rによるベイジアンネットワーク入門
Rによるベイジアンネットワーク入門
 
ブースティング入門
ブースティング入門ブースティング入門
ブースティング入門
 
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
 
R言語による アソシエーション分析-組合せ・事象の規則を解明する-(第5回R勉強会@東京)
R言語による アソシエーション分析-組合せ・事象の規則を解明する-(第5回R勉強会@東京)R言語による アソシエーション分析-組合せ・事象の規則を解明する-(第5回R勉強会@東京)
R言語による アソシエーション分析-組合せ・事象の規則を解明する-(第5回R勉強会@東京)
 
グラフニューラルネットワーク入門
グラフニューラルネットワーク入門グラフニューラルネットワーク入門
グラフニューラルネットワーク入門
 
第五回統計学勉強会@東大駒場
第五回統計学勉強会@東大駒場第五回統計学勉強会@東大駒場
第五回統計学勉強会@東大駒場
 
画像処理基礎
画像処理基礎画像処理基礎
画像処理基礎
 
【読書会資料】『StanとRでベイズ統計モデリング』Chapter12:時間や空間を扱うモデル
【読書会資料】『StanとRでベイズ統計モデリング』Chapter12:時間や空間を扱うモデル【読書会資料】『StanとRでベイズ統計モデリング』Chapter12:時間や空間を扱うモデル
【読書会資料】『StanとRでベイズ統計モデリング』Chapter12:時間や空間を扱うモデル
 
機械学習モデルの列挙
機械学習モデルの列挙機械学習モデルの列挙
機械学習モデルの列挙
 
社会心理学者のための時系列分析入門_小森
社会心理学者のための時系列分析入門_小森社会心理学者のための時系列分析入門_小森
社会心理学者のための時系列分析入門_小森
 
グラフデータの機械学習における特徴表現の設計と学習
グラフデータの機械学習における特徴表現の設計と学習グラフデータの機械学習における特徴表現の設計と学習
グラフデータの機械学習における特徴表現の設計と学習
 
2部グラフとソーシャルネットワーク
2部グラフとソーシャルネットワーク2部グラフとソーシャルネットワーク
2部グラフとソーシャルネットワーク
 
計量時系列分析の立場からビジネスの現場のデータを見てみよう - 30th Tokyo Webmining
計量時系列分析の立場からビジネスの現場のデータを見てみよう - 30th Tokyo Webmining計量時系列分析の立場からビジネスの現場のデータを見てみよう - 30th Tokyo Webmining
計量時系列分析の立場からビジネスの現場のデータを見てみよう - 30th Tokyo Webmining
 
Visual Studio CodeでRを使う
Visual Studio CodeでRを使うVisual Studio CodeでRを使う
Visual Studio CodeでRを使う
 
因果推論を用いた 群衆移動の誘導における介入効果推定
因果推論を用いた 群衆移動の誘導における介入効果推定因果推論を用いた 群衆移動の誘導における介入効果推定
因果推論を用いた 群衆移動の誘導における介入効果推定
 
グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?
 
ベイジアンネットとレコメンデーション -第5回データマイニング+WEB勉強会@東京
ベイジアンネットとレコメンデーション -第5回データマイニング+WEB勉強会@東京ベイジアンネットとレコメンデーション -第5回データマイニング+WEB勉強会@東京
ベイジアンネットとレコメンデーション -第5回データマイニング+WEB勉強会@東京
 

Similar to {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 visualization
Liang (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 4
Kevin Chun-Hsien Hsu
 
R lecture oga
R lecture ogaR lecture oga
R lecture oga
Osamu Ogasawara
 
Map, Reduce and Filter in Swift
Map, Reduce and Filter in SwiftMap, Reduce and Filter in Swift
Map, Reduce and Filter in Swift
Aleksandras Smirnovas
 
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 collections
Myeongin Woo
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)riue
 
library(sparkline)
library(sparkline)library(sparkline)
library(sparkline)
Dr. Volkan OBAN
 
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
Howard 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.pdf
kesav24
 
Python Lecture 11
Python Lecture 11Python Lecture 11
Python Lecture 11
Inzamam Baig
 
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 datatypes
Adheetha O. V
 
Zippers
ZippersZippers
Zippers
David Overton
 
List out of lambda
List out of lambdaList out of lambda
List out of lambda
Vyatcheslav Potravnyy
 
Артём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data AnalysisАртём Акуляков - F# for Data Analysis
Артём Акуляков - F# for Data Analysis
SpbDotNet Community
 

Similar to {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
 

More from Takashi Kitano

好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
Takashi Kitano
 
令和から本気出す
令和から本気出す令和から本気出す
令和から本気出す
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章 公開ver
Takashi Kitano
 
20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyor20140625 rでのデータ分析(仮) for_tokyor
20140625 rでのデータ分析(仮) for_tokyor
Takashi Kitano
 
lubridateパッケージ入門
lubridateパッケージ入門lubridateパッケージ入門
lubridateパッケージ入門
Takashi Kitano
 
20150329 tokyo r47
20150329 tokyo r4720150329 tokyo r47
20150329 tokyo r47
Takashi Kitano
 
20140920 tokyo r43
20140920 tokyo r4320140920 tokyo r43
20140920 tokyo r43
Takashi Kitano
 
Google's r style guideのすゝめ
Google's r style guideのすゝめGoogle's r style guideのすゝめ
Google's r style guideのすゝめTakashi Kitano
 

More from Takashi Kitano (12)

好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
好みの日本酒を呑みたい! 〜さけのわデータで探す自分好みの酒〜
 
令和から本気出す
令和から本気出す令和から本気出す
令和から本気出す
 
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のすゝめ
 

Recently uploaded

SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
nscud
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
MaleehaSheikh2
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
vcaxypu
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
ewymefz
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 

Recently uploaded (20)

SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 

{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() })