Skip to content

Commit 380d5f4

Browse files
committed
rename mn_res -> res_mn; notes on how to get all reservations
1 parent b4b4467 commit 380d5f4

File tree

7 files changed

+28
-13
lines changed

7 files changed

+28
-13
lines changed

Diff for: R/data.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
#'
3030
#' @format An sf data frame with 13 features and 5 fields
3131
#'
32-
"mn_res"
32+
"res_mn"

Diff for: data-raw/mn.R renamed to data-raw/res-mn.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ res <- st_read(file.path(dirname(f), "reservtn.shp"))
99
# https://www.dot.state.mn.us/maps/gdma/gis-data.html
1010
st_crs(res) <- 26915
1111

12-
mn_res <- st_transform(res, 4326)
12+
res_mn <- st_transform(res, 4326)
1313

14-
# plot_mapbox(mn_res, text = ~INDRESNAME, hoverinfo = "text")
15-
devtools::use_data(mn_res, overwrite = TRUE)
14+
# plot_mapbox(res_mn, text = ~INDRESNAME, hoverinfo = "text")
15+
devtools::use_data(res_mn, overwrite = TRUE)
1616

1717

1818
# f <- tempfile(fileext = ".zip")

Diff for: data-raw/res-us.R

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
library(sf)
2+
3+
# https://www.census.gov/cgi-bin/geo/shapefiles/index.php?year=2017&layergroup=American+Indian+Area+Geography
4+
# click 'American Indian/Alaska Native/Native Hawaiian Area'
5+
res <- sf::st_read("~/Downloads/tl_2017_us_aiannh/tl_2017_us_aiannh.shp")
6+
7+
# TODO:
8+
# (1) simplify shape file!!
9+
# (2) crosstalk highlight should set fillcolor...
10+
11+
res %>%
12+
SharedData$new(~NAME) %>%
13+
plot_ly(text = ~NAME) %>%
14+
highlight(selectize = TRUE, dynamic = TRUE)
15+

Diff for: data/mn_res.rda

-528 KB
Binary file not shown.

Diff for: data/res_mn.rda

528 KB
Binary file not shown.

Diff for: man/mn_res.Rd renamed to man/res_mn.Rd

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: tests/testthat/test-plotly-sf.R

+6-6
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ test_that("plot_ly() defaults to blank axes", {
103103
})
104104

105105
test_that("discrete color informs fillcolor", {
106-
res <- unique(mn_res$INDRESNAME)
106+
res <- unique(res_mn$INDRESNAME)
107107
cols <- viridisLite::magma(length(res))
108108

109-
p <- plot_mapbox(mn_res, color = ~INDRESNAME, colors = cols) %>%
109+
p <- plot_mapbox(res_mn, color = ~INDRESNAME, colors = cols) %>%
110110
plotly_build()
111111

112112
d <- p$x$data
@@ -122,10 +122,10 @@ test_that("discrete color informs fillcolor", {
122122

123123

124124
test_that("discrete color informs fillcolor", {
125-
res <- unique(mn_res$INDRESNAME)
125+
res <- unique(res_mn$INDRESNAME)
126126
cols <- viridisLite::magma(length(res))
127127

128-
p <- plot_mapbox(mn_res, color = ~INDRESNAME, colors = cols) %>%
128+
p <- plot_mapbox(res_mn, color = ~INDRESNAME, colors = cols) %>%
129129
plotly_build()
130130

131131
d <- p$x$data
@@ -141,15 +141,15 @@ test_that("discrete color informs fillcolor", {
141141

142142

143143
test_that("numeric color informs fillcolor", {
144-
res <- unique(mn_res$INDRESNAME)
144+
res <- unique(res_mn$INDRESNAME)
145145
cols <- viridisLite::magma(length(res))
146146
p <- plot_mapbox(mn_res, split = ~INDRESNAME, color = ~AREA, colors = cols, showlegend = FALSE, line = list(color = "black")) %>%
147147
plotly_build()
148148

149149
d <- p$x$data
150150
expect_length(d, length(res) + 1)
151151

152-
area <- unique(mn_res$AREA)
152+
area <- unique(res_mn$AREA)
153153
fillcolors <- unlist(lapply(d, "[[", "fillcolor"))
154154
expect_identical(sort(fillcolors), sort(scales::col_numeric(cols, range(area))(area)))
155155

0 commit comments

Comments
 (0)