Skip to content

Commit 14f1172

Browse files
committed
Fix subnational codes
1 parent 9ba9072 commit 14f1172

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

vignettes/articles/1.3-ViewData.Rmd

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ All contributing members of NatureCounts have complete authority over the use of
4949
You can view the Data Access Level for each collection on the [NatureCounts Datasets](https://naturecounts.ca/nc/default/datasets.jsp) page or using the [metadata](#Data3.5) function (see `akn_level`):
5050

5151
```{r access, eval = FALSE}
52-
collections<-meta_collections()
52+
collections <- meta_collections()
5353
View(collections)
5454
```
5555

@@ -133,8 +133,8 @@ There are [metadata](https://birdstudiescanada.github.io/naturecounts/reference/
133133
Any of these functions can be used to browse the code lists relevant to your search. For example, you can view the metadata for Birds Canada projects, including project ids using:
134134

135135
```{r meta, eval = FALSE}
136-
project_ids <- meta_projects() # retrieve the project_ids represented in the repository
137-
View(project_ids) # explore the dataframe
136+
project_ids <- meta_projects() # retrieve the project_ids represented in the repository
137+
View(project_ids) # explore the dataframe
138138
```
139139

140140
Using the above functions to search by country, state/province, subnational2, BCR etc. is especially useful for regional filtering in this next section.
@@ -176,7 +176,7 @@ When using the `nc_count()` view function, you have the helpful option of filter
176176
First, let's limit our data search to Quebec:
177177

178178
```{r nc_count example, eval=FALSE}
179-
nc_count(region = list(statprov="QC")) # filter nc_count by statprov
179+
nc_count(region = list(statprov = "QC")) # filter nc_count by statprov
180180
```
181181

182182
Next, let's say we want to narrow down our search to the subnational level (Montreal and Toronto) but don't know the corresponding codes for these regions.
@@ -191,19 +191,21 @@ Or, more efficiently, search by region:
191191

192192
```{r}
193193
search_region("Montreal", type = "subnational2")
194+
search_region("Toronto", type = "subnational2")
194195
```
195196

196197
Great, we now know the codes we need and can view our metadata using `nc_count()`:
197198

198199
```{r}
199-
nc_count(region = list(subnational2 = c("CA-QC-MR", "CA-ON-TO")))
200+
nc_count(region = list(subnational2 = c("CA.QC.MR", "CA.ON.TO")))
200201
```
201202

202203
Similarly, this function can be used to view metadata for a bounding box using latitude and longitude coordinates:
203204

204205
```{r}
205-
nc_count(region = list(bbox = c(left = -125, bottom = 45,
206-
right = -100, top = 50)))
206+
nc_count(
207+
region = list(bbox = c(left = -125, bottom = 45, right = -100, top = 50))
208+
)
207209
```
208210

209211
Another commonly used filter is specific to `species`. In order to filter by `species` you need to get the species id codes. These are numeric codes that reflect species identity.
@@ -285,7 +287,7 @@ The following code will retrieve all available collections and number of records
285287
search_species("Red-headed Woodpecker")
286288
search_species_code("RHWO")
287289
288-
RHWO<-nc_count(species = 10060)
290+
RHWO <- nc_count(species = 10060)
289291
View(RHWO)
290292
```
291293

@@ -298,7 +300,11 @@ View(RHWO_11)
298300
RHWO_year <- nc_count(species = 10060, year = c(2015, 2019))
299301
View(RHWO_year)
300302
301-
RHWO_11_year <- nc_count(species = 10060, region = list(bcr = "11"), year = c(2015, 2019))
303+
RHWO_11_year <- nc_count(
304+
species = 10060,
305+
region = list(bcr = "11"),
306+
year = c(2015, 2019)
307+
)
302308
View(RHWO_11_year)
303309
```
304310

0 commit comments

Comments
 (0)