-
Notifications
You must be signed in to change notification settings - Fork 3
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
Finalize n_species
, deprecate/defunct other functions, add CITATION.cff
#346
Conversation
Added affiliation in #342 but forgot to compile documentation.
Use example without DOI and date release.
All other tests are removed as taxa is reexported from camtrapdp.
No need to have two situations in same observation data.frame
Via `cffr::cff_write()` + remove doi line
get_species is deprecated, so we needed to use another function.
Filter happens via filter_observations() now.
Infinite loop otherwise :-)
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.
Nice!
I have 1 remark about filtering on observationLevel & a suggestion for simplification.
R/n_species.R
Outdated
# Extract observations and deployments | ||
observations <- observations(x) | ||
# Extract event-based observations and deployments | ||
observations <- observations(x) %>% |
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.
I suggest:
x <- filter_observations(.data$observationLevel == "event")
and using observations(x)
instead of observations
.
Because what if there is a deployment with only media-based observations?
It would now not be noticed in L33: deployments_no_obs <- get_dep_no_obs(x)
.
And last, why is the count reduced by NA-values in a mutate-function, and not like this?:
n_species <-
species %>%
dplyr::filter(!is.na(.data$scientificName)) %>%
dplyr::group_by(.data$deploymentID) %>%
dplyr::count() %>%
dplyr::ungroup()
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.
Fully agree with first suggestion 🔝 Implemented in 28ae966 and 328a573.
About the reason why I use a mutate to not count NA as species: I agreed with you at the beginning , but then thanks to a failing test (A perfect example of the need of unit-tests!) I found the reason I wrote that few years ago 😄 We need to assign 0 to deployments with ONLY unidentified species (scientificName
= NA
). To do that, the shortest way I found was to do a standard group_by() %>% count()
and then reducing the sum by one. I improved the comments in the code to better understand this for future-me and everybody else.
I also ordered the output by using the original order as provided in deployment table. Tests added to check this. Also added a test to check that deployments without event-based observations have |
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.
Well done, I have no comments!
This pull request includes several changes to the codebase, focusing on:
n_species()
and its testsFinalizing
n_species()
and its testsUp to now, tests were not really taken into account as we were way far from getting the functions ready to the new format. From this PR we can start using them 🥳 as the very first function,
n_species()
, is ready! So, please rundevtools::test(filter = "n_species")
as check. Its related tests have been simplified without losing testing power. Notice that we only consider event based observations for the standard functions of camtraptor v1.0.0 (#332).Deprecation of functions
get_species()
function in favor oftaxa()
(fix Deprecateget_species()
#343)get_scientific_name()
andcheck_species()
functions are defunct in favor oftaxa()
(fix Removecheck_species()
,get_scientific_name()
#235). So,check_species()
andget_scientific_name()
functions are moved todefunct.R
.Metadata
CITATION.cff
(fix AddCITATION.cff
#345) (usingcffr::cff_write()
).Documentation updates
n_species
instead of the deprecatedget_species
. This has been done by using@inheritParams n_species
instead of@inheritParams get_n_species
.NEWS.md
file to reflect the deprecation/defunct of several functions, the introduction of new replacements and new citation file.Other code improvements
get_n_individuals()
andget_n_obs()
functions by removing thespecies
parameter and associated logic: we do not filter anymore within such functions, only viafilter_observations()
. IMPORTANT: these functions are still not finalized and do not follow the new data standard still. So, they will fail or return a non tested result.