-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New function merge_camtrapdp()
#112
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #112 +/- ##
==========================================
+ Coverage 99.89% 99.91% +0.01%
==========================================
Files 23 24 +1
Lines 983 1211 +228
==========================================
+ Hits 982 1210 +228
Misses 1 1 ☔ View full report in Codecov by Sentry. |
…'s and observationID's"
…nerate_deploymentID()`
9da984f
to
19f98bd
Compare
eventID = FALSE) | ||
|
||
deploymentIDs <- c( | ||
unique(purrr::pluck(deployments(x), "deploymentID")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can deploymentID
be missing from deployments(x)
? If not, then purrr::chuck()
will throw an error if it is missing, thus making the line a little bit more defensive.
unique(purrr::pluck(deployments(x), "deploymentID")), | |
unique(purrr::chuck(deployments(x), "deploymentID")), |
|
||
deploymentIDs <- c( | ||
unique(purrr::pluck(deployments(x), "deploymentID")), | ||
unique(purrr::pluck(deployments(y), "deploymentID")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique(purrr::pluck(deployments(y), "deploymentID")) | |
unique(purrr::chuck(deployments(y), "deploymentID")) |
unique(purrr::pluck(media(x), "mediaID")), | ||
unique(purrr::pluck(media(y), "mediaID")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique(purrr::pluck(media(x), "mediaID")), | |
unique(purrr::pluck(media(y), "mediaID")) | |
unique(purrr::chuck(media(x), "mediaID")), | |
unique(purrr::chuck(media(y), "mediaID")) |
unique(purrr::pluck(observations(x), "observationID")), | ||
unique(purrr::pluck(observations(y), "observationID")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique(purrr::pluck(observations(x), "observationID")), | |
unique(purrr::pluck(observations(y), "observationID")) | |
unique(purrr::chuck(observations(x), "observationID")), | |
unique(purrr::chuck(observations(y), "observationID")) |
unique(purrr::pluck(media(x), "eventID")), | ||
unique(purrr::pluck(media(y), "eventID")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique(purrr::pluck(media(x), "eventID")), | |
unique(purrr::pluck(media(y), "eventID")) | |
unique(purrr::chuck(media(x), "eventID")), | |
unique(purrr::chuck(media(y), "eventID")) |
) | ||
|
||
# Check for duplicates | ||
if (any(duplicated(deploymentIDs))) {result$deploymentID <- TRUE} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyDuplicated()
?
# Add unique resources from y | ||
y_unique_resources <- | ||
y_additional_resources[!y_additional_resources %in% duplicated_names] | ||
purrr::map(y_unique_resources, function(resource_name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could purrr::imap()
make this a bit easier instead of having to create the index in the anonymous function?
unique_data_list <- | ||
purrr::map(unique_data, function(x) { | ||
x <- as.list(x) | ||
x[!sapply(x, is.na)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sapply()
is not type safe, and will set off ropensci review alarms!
I only had a brief look, but an more in depth review of Peter is coming up. |
fix #75
Remarks
Helper functions
I created 6 helper functions. Maybe they can be simplified or reduced in number!
They now live at utils.R.
merge_camtrapdp()
check_duplicate_ids()
add_prefix()
normalize_list()
is_subset()
update_unique()
remove_duplicates()