Skip to content

Commit

Permalink
Release v.0.3.1
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
mpjashby committed Jun 18, 2022
1 parent 921b48e commit 798d1f4
Show file tree
Hide file tree
Showing 26 changed files with 63 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
^_pkgdown\.yml$
^docs$
^pkgdown$
^CRAN-SUBMISSION$
^\.github$
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: crimedata
Title: Access Crime Data from the Open Crime Database
Version: 0.3.0
Version: 0.3.1
Authors@R: person("Matthew", "Ashby", email = "matthew.ashby@ucl.ac.uk",
role = c("aut", "cre"),
role = c("aut", "cre", "cph"),
comment = c(ORCID = "<https://orcid.org/0000-0003-4201-9239>"))
Description: Gives convenient access to publicly available police-recorded open
crime data from large cities in the United States that are included in the
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# crimedata 0.3.1

* Fixed an error with downloading some data for 2020 that was caused by a
change in the OSF API used to query the data.


# crimedata 0.3.0

* Errors, warnings and messages are now generated using `rlang` to make them
Expand Down
4 changes: 2 additions & 2 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' obtained from the \href{https://osf.io/zyaqn/}{Crime Open Database}.
#'
#' More details of the data format are available on the
#' \href{https://osf.io/zyaqn/wiki/}{Crime Open Database website}.
#' \href{https://osf.io/zyaqn/wiki/home/}{Crime Open Database website}.
#' Variables marked * are only available for some of the
#' data, due to limitations in the data published by some cities.
#'
Expand Down Expand Up @@ -43,7 +43,7 @@
#' \href{https://osf.io/zyaqn/}{Crime Open Database}.
#'
#' More details of the data format are available on the
#' \href{https://osf.io/zyaqn/wiki/}{Crime Open Database website}.
#' \href{https://osf.io/zyaqn/wiki/home/}{Crime Open Database website}.
#' Variables marked * are only available for some of the
#' data, due to limitations in the data published by some cities.
#'
Expand Down
14 changes: 11 additions & 3 deletions R/get_crime_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ get_crime_data <- function(
crime_data,
dplyr::vars(dplyr::one_of(c(
"city_name", "offense_code", "offense_type", "offense_group",
"offense_against", "location_type", "location_category"
"offense_against"
))),
as.factor
)
Expand All @@ -275,14 +275,22 @@ get_crime_data <- function(
dplyr::vars("date_single"),
as.POSIXct, format = "%Y-%m-%d %H:%M"
)
if (
"location_type" %in% names(crime_data) |
"location_category" %in% names(crime_data)
) {
crime_data <- dplyr::mutate_at(
crime_data,
dplyr::vars(dplyr::one_of(c("location_type", "location_category"))),
as.factor
)
}
if ("date_start" %in% names(crime_data) | "date_end" %in% names(crime_data)) {

crime_data <- dplyr::mutate_at(
crime_data,
dplyr::vars(dplyr::one_of(c("date_start", "date_end"))),
as.POSIXct, format = "%Y-%m-%d %H:%M"
)

}

# return data
Expand Down
5 changes: 3 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ New submission

Package was archived on CRAN

* This package was archived due to an out-of-date maintainer email address,
which I have now fixed.
* This package was archived due to an out-of-date maintainer email address and
a problem with one of the tests of `get_crime_data()`. Both these issues have
been fixed.
* win-builder gives an 'Invalid DOI' message for the DOI
https://doi.org/10.1163/24523666-00401007 but this DOI is valid.
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/articles/introduction.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pkgdown: 2.0.4
pkgdown_sha: ~
articles:
introduction: introduction.html
last_built: 2022-06-14T11:39Z
last_built: 2022-06-18T21:43Z
urls:
reference: http://pkgs.lesscrime.info/crimedata/reference
article: http://pkgs.lesscrime.info/crimedata/articles
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/block_geoid_to.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/reference/crimedata.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/get_crime_data.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/reference/homicides15.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions docs/reference/list_crime_data.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/reference/nycvehiclethefts.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GEOID
GEOIDs
Lifecycle
NIBRS
OSF
WGS
blockgroup
dplyr
Expand Down
2 changes: 1 addition & 1 deletion man/homicides15.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/nycvehiclethefts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/testthat/test_get_crime_data.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
context("Test function to get crime data")

test_that("return value of get_crime_data is a tibble or SF object", {
expect_is(get_crime_data(years = 2019), "tbl_df")
expect_is(get_crime_data(years = 2019, output = "sf"), "sf")
expect_is(get_crime_data(), "tbl_df")
expect_is(get_crime_data(output = "sf"), "sf")
})

test_that("incorrect arguments produce errors", {
Expand Down Expand Up @@ -52,17 +52,17 @@ test_that("quiet execution does not return any messages", {
test_that("data cache works as expected", {

# get data, which should then be cached
get_crime_data(years = 2019, cities = "Detroit")
get_crime_data(cities = "Detroit")

# request data again and check if it is retrieved from the cache
expect_message(
get_crime_data(years = 2019, cities = "Detroit"),
get_crime_data(cities = "Detroit"),
"Loading cached data"
)

# request data again, forcing download from server
expect_message(
get_crime_data(years = 2019, cities = "Detroit", cache = FALSE),
get_crime_data(cities = "Detroit", cache = FALSE),
"Deleting cached data"
)
})

0 comments on commit 798d1f4

Please sign in to comment.