I have run into an issue when calculating the density effects from get_delta_stats() in mobr_2.0.2. From what I can tell, the rarefaction function shortens the effort vector for all effort/dens_ratio > n when calculating S_N rarefaction. It is my understanding from rarefaction description that it should pass the observed number of species when effort (in this case, effort/dens_ratio) > n and extrapolate == FALSE. From rarefaction() documentation:
"If effort is greater than sample size and extrapolate = FALSE then the observed number of species is returned."
However, it drops these effort values (from rarefaction() effort = effort[effort/dens_ratio <= n) and I can't find when/if the observed S is replaced. This leads to an altered vector length and error when attempting to create a data frame:
""Error in data.frame(test = "N", sample = "indiv", effort = inds, S = S_N, :
arguments imply differing number of rows:"
Very possible I am misunderstanding the issue or missed where it is discussed and am misapplying the method. Any help or clarification would be appreciated.
This throws the error:
"Error in data.frame(test = "N", sample = "indiv", effort = inds, S = S_N, :
arguments imply differing number of rows: 1, 16, 15"
Thanks again.
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
attached base packages:
[1] parallel grid stats graphics grDevices utils datasets methods base
I have run into an issue when calculating the density effects from
get_delta_stats()
in mobr_2.0.2. From what I can tell, the rarefaction function shortens the effort vector for all effort/dens_ratio > n when calculating S_N rarefaction. It is my understanding fromrarefaction
description that it should pass the observed number of species when effort (in this case, effort/dens_ratio) > n andextrapolate == FALSE
. From rarefaction() documentation:"If effort is greater than sample size and extrapolate = FALSE then the observed number of species is returned."
However, it drops these effort values (from rarefaction()
effort = effort[effort/dens_ratio <= n
) and I can't find when/if the observed S is replaced. This leads to an altered vector length and error when attempting to create a data frame:""Error in data.frame(test = "N", sample = "indiv", effort = inds, S = S_N, : arguments imply differing number of rows:"
Very possible I am misunderstanding the issue or missed where it is discussed and am misapplying the method. Any help or clarification would be appreciated.
Cheers.
Code to reproduce the issue:
First the community and plot attribute data:
Converting with
make_mob_in
and attempting to get delta statistics:This throws the error: "Error in data.frame(test = "N", sample = "indiv", effort = inds, S = S_N, : arguments imply differing number of rows: 1, 16, 15"
Thanks again.
sessionInfo()
R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042)attached base packages: [1] parallel grid stats graphics grDevices utils datasets methods base
other attached packages: [1] gplots_3.1.1 usedist_0.4.0 pairwiseAdonis_0.4 cluster_2.1.0 vegan_2.5-7
[6] lattice_0.20-41 permute_0.9-5 mobr_2.0.2 taxize_0.9.99 rfishbase_3.1.8
[11] gtable_0.3.0 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.7 purrr_0.3.4
[16] readr_2.0.2 tidyr_1.1.3 tibble_3.1.3 ggplot2_3.3.5 tidyverse_1.3.1
[21] readxl_1.3.1 rmarkdown_2.9 styler_1.5.1 here_1.0.1 pacman_0.5.1
[26] devtools_2.4.2 usethis_2.0.1