-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Note for self: In future versions of Camtrap DP, columns might get renamed (e.g. cameraHeight -> deviceHeight).
- 👍 The
upgrade()function (called byread_camtrapdp()) will automatically rename columns to the latest version of Camtrap DP. - 👎 Users providing old names in the
filter_functions will get an error (column not found). This will be especially confusing because the old column name still exists in their files on disk.
We should therefore warn users + rename the columns in the filter functions, so the behaviour is this:
library(camtrapdp)
x <- read_camtrapdp("http://raw.githubusercontent.com/tdwg/camtrap-dp/1.0/example/datapackage.json")
filter_deployments(x, cameraHeight >= 1.0)
#> Warning: cameraHeight has been renamed to deviceHeight. Please update your filter.
#>
#> A Camera Trap Data Package "camtrap-dp-example-dataset" with 3 tables:
#> • deployments: 2 rows
#> • media: 240 rows
#> • observations: 339 rows
#>
#> And 1 additional resource:
#> • individualsTo capture the ... of filter_deployments(), convert it to a vector to rename values and convert it back to ... use rlang::quos() and !!!. See:
Lines 17 to 21 in e465370
| mutate_if_missing <- function(.data, ...) { | |
| args <- rlang::quos(...) | |
| new_columns <- args[!names(args) %in% colnames(.data)] | |
| dplyr::mutate(.data, !!!new_columns) | |
| } |
Metadata
Metadata
Assignees
Labels
No labels