-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from inbo/add-locations-function
Add locations function
- Loading branch information
Showing
13 changed files
with
131 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
|
||
## usethis namespace: start | ||
#' @importFrom dplyr %>% | ||
#' @importFrom dplyr .data | ||
## usethis namespace: end | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' Get locations | ||
#' | ||
#' Gets the unique locations from the deployments of a Camera Trap Data Package | ||
#' object. | ||
#' | ||
#' @inheritParams version | ||
#' @return [tibble()] data frame with the following columns: | ||
#' - `locationID` | ||
#' - `locationName` | ||
#' - `latitude` | ||
#' - `longitude` | ||
#' - `coordinateUncertainty` | ||
#' @family accessor functions | ||
#' @export | ||
#' @examples | ||
#' x <- example_dataset() | ||
#' locations(x) | ||
locations <- function(x) { | ||
check_camtrapdp(x) | ||
deployments(x) %>% | ||
dplyr::distinct( | ||
.data$locationID, | ||
.data$locationName, | ||
.data$latitude, | ||
.data$longitude, | ||
.data$coordinateUncertainty | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
test_that("locations() returns a tibble", { | ||
skip_if_offline() | ||
x <- example_dataset() | ||
expect_s3_class(locations(x), "tbl") | ||
}) | ||
|
||
test_that("locations() returns expected columns", { | ||
skip_if_offline() | ||
x <- example_dataset() | ||
expected_cols <- c( | ||
"locationID", | ||
"locationName", | ||
"latitude", | ||
"longitude", | ||
"coordinateUncertainty" | ||
) | ||
expect_named(locations(x), expected_cols) | ||
}) | ||
|
||
test_that("locations() returns unique location information", { | ||
skip_if_offline() | ||
x <- example_dataset() | ||
expect_equal(nrow(locations(x)), 4) | ||
# TODO: reduce cardinality of location information in deployments and expect fewer rows | ||
}) |