Skip to content

control for fail when effort = NA and index = 'S_n' #257

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

Merged
merged 1 commit into from
Dec 3, 2020

Conversation

AlbanSagouis
Copy link
Contributor

In calc_div, instead of deleting the default parameter for effort, a similar check as in calc_comm_div could be made.
With this change, the errors are more informative:
Before:

> data(inv_comm)
> calc_comm_div(inv_comm, 'S_n')
Error in if (any(effort > n)) { : missing value where TRUE/FALSE needed
> calc_div(inv_comm[1,], 'S_n')
Error in if (any(effort > n)) { : missing value where TRUE/FALSE needed

After:

> calc_comm_div(inv_comm, 'S_n')
Error in calc_comm_div(inv_comm, "S_n") : 
  effort value is needed to compute S_n
> calc_div(inv_comm[1, ], 'S_n')
Error in rarefaction(x, method = "IBR", effort = effort, ...) : 
  argument "effort" is missing, with no default

@dmcglinn
Copy link
Member

dmcglinn commented Dec 3, 2020

Thanks @AlbanSagouis ! This seems totally reasonable. In the master branch of the repo we use the function get_mob_stats to feed the function calc_biodiv effort levels even when they are not supplied by the user: https://github.com/MoBiodiv/mobr/blob/master/R/mobr_boxplots.R#L615-L626

I think we'll continue that kind of implementation, but your patch is helpful because some users will just want to use calc_div and calc_comm_div directly. Tagging Issue #256

@dmcglinn dmcglinn merged commit 0070bcc into MoBiodiv:dev Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants