Skip to content

Commit

Permalink
Merge pull request #248 from ropensci/239-get_stats19
Browse files Browse the repository at this point in the history
Set year to 1979 if earlier than 2018, close #239
  • Loading branch information
Robinlovelace authored Jul 31, 2024
2 parents 4b9074a + b6d09a9 commit 62f9067
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# stats19 3.1.0 2024-07

* stats19 now relies on the `stats19_variables` object to format the different tables columns (#245) (credit @layik), fixing an issue in which ages were removed from the `casualties` table, fixing (#235)
* If `year` is less than 2018 the package auto-downloads the full dataset (#239)

# stats19 3.0.3 2024-02

Expand Down
5 changes: 5 additions & 0 deletions R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ get_stats19 = function(year = NULL,
output_format = "tibble"
}

# Update year to 1979 if it's NULL or before 2018:
if (is.null(year) || year < 2018) {
year = 1979
}

# download what the user wanted
dl_stats19(year = year,
type = type,
Expand Down
11 changes: 11 additions & 0 deletions data-raw/tests/test-year.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
format: gfm
---

Test date:


```{r}
devtools::load_all()
crashes = get_stats19(year = 2005, type = "accidents")
```

0 comments on commit 62f9067

Please sign in to comment.