Skip to content

Commit 700fa97

Browse files
also apply to README
1 parent 92cf1e0 commit 700fa97

3 files changed

Lines changed: 19 additions & 23 deletions

File tree

.lintr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ linters: linters_with_defaults(
1010
expect_s4_class_linter(),
1111
expect_true_false_linter(),
1212
expect_type_linter(),
13+
numeric_leading_zero_linter(),
1314
implicit_integer_linter(allow_colon = TRUE),
1415
indentation_linter(hanging_indent_style = "never"),
1516
infix_spaces_linter(exclude_operators = c("=", "*", "/")),

README.Rmd

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ suppressPackageStartupMessages(library(data.table))
6060
art = fread(URL)
6161
6262
# count art by geohash
63-
art[ , .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 5L))
64-
# only show the top 10
65-
][order(-N)][1:10]
63+
gh_freq = art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 5L))]
64+
# only show the top 10
65+
gh_freq[order(-N)][1:10]
6666
```
6767

6868
This is pretty impractical _per se_ (where is `dp3wm`?); we'll return to this once we've introduced more functionality.
@@ -115,29 +115,26 @@ Returning to public art locations in Chicago, we can visualize the spatial aggre
115115
#| fig.width = 8,
116116
#| fig.height = 8,
117117
#| out.width = '\\textwidth'
118-
119118
library(sf)
120-
# for pretty coloring
121-
library(colourvalues)
122119
123120
## first, pull neighborhood shapefiles from https://data.cityofchicago.org
124-
tmp = tempfile(fileext = ".zip")
121+
tmp = tempfile(fileext = '.zip')
125122
shp_url = file.path(
126-
api_stem, '9wp7-iasj/files',
123+
api_stem, '9wp7-iasj', 'files',
127124
'TMTPQ_MTmUDEpDGCLt_B1uaiJmwhCKZ729Ecxq6BPfM?filename=Neighborhoods_2012.zip'
128125
)
129126
download.file(shp_url, tmp)
130127
131-
chicago = paste0("/vsizip/", tmp) |>
128+
chicago = paste0('/vsizip/', tmp) |>
132129
st_read(quiet = TRUE) |>
133130
st_transform(crs = 4326L)
134131
135132
artSF = gh_to_sf(
136-
art[ , .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 6L))],
133+
art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 6L))],
137134
gh_col = 'geohash'
138135
)
139-
plot(st_geometry(chicago), lwd = .5, main = 'Public Art Locations in Chicago')
140-
plot(artSF["N"], add = TRUE)
136+
plot(st_geometry(chicago), lwd = 0.5, main = 'Public Art Locations in Chicago')
137+
plot(artSF['N'], add = TRUE)
141138
```
142139

143140
Chicago connoisseurs will recognize the biggest concentration around Lincoln Park, with another concentration along the waterfront near Millenium/Grant Parks.

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ suppressPackageStartupMessages(library(data.table))
5757
art = fread(URL)
5858

5959
# count art by geohash
60-
art[ , .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 5L))
61-
# only show the top 10
62-
][order(-N)][1:10]
60+
gh_freq = art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 5L))]
61+
# only show the top 10
62+
gh_freq[order(-N)][1:10]
6363
```
6464

6565
```
@@ -178,27 +178,25 @@ Returning to public art locations in Chicago, we can visualize the spatial aggre
178178

179179
```r
180180
library(sf)
181-
# for pretty coloring
182-
library(colourvalues)
183181

184182
## first, pull neighborhood shapefiles from https://data.cityofchicago.org
185-
tmp = tempfile(fileext = ".zip")
183+
tmp = tempfile(fileext = '.zip')
186184
shp_url = file.path(
187-
api_stem, '9wp7-iasj/files',
185+
api_stem, '9wp7-iasj', 'files',
188186
'TMTPQ_MTmUDEpDGCLt_B1uaiJmwhCKZ729Ecxq6BPfM?filename=Neighborhoods_2012.zip'
189187
)
190188
download.file(shp_url, tmp)
191189

192-
chicago = paste0("/vsizip/", tmp) |>
190+
chicago = paste0('/vsizip/', tmp) |>
193191
st_read(quiet = TRUE) |>
194192
st_transform(crs = 4326L)
195193

196194
artSF = gh_to_sf(
197-
art[ , .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 6L))],
195+
art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 6L))],
198196
gh_col = 'geohash'
199197
)
200-
plot(st_geometry(chicago), lwd = .5, main = 'Public Art Locations in Chicago')
201-
plot(artSF["N"], add = TRUE)
198+
plot(st_geometry(chicago), lwd = 0.5, main = 'Public Art Locations in Chicago')
199+
plot(artSF['N'], add = TRUE)
202200
```
203201

204202
<div class="figure">

0 commit comments

Comments
 (0)