Skip to content

Commit

Permalink
version 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosP-Carmona authored and cran-robot committed Feb 12, 2020
1 parent 04d5e86 commit 0aa0607
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 48 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
@@ -1,10 +1,10 @@
Package: DarkDiv
Type: Package
Title: Estimating Probabilistic Dark Diversity
Version: 0.1.0
Title: Estimating Dark Diversity and Site-Specific Species Pools
Version: 0.2.0
Author: Carlos P. Carmona
Maintainer: Carlos P. Carmona <perezcarmonacarlos@gmail.com>
Description: Estimation of dark diversity using species co-occurrences.
Description: Estimation of dark diversity and site-specific species pools using species co-occurrences.
It includes implementations of probabilistic dark diversity based on the
Hypergeometric distribution, as well as estimations based on the Beals index,
which can be transformed to binary predictions using different thresholds,
Expand All @@ -22,6 +22,6 @@ RoxygenNote: 6.1.1
Imports: vegan, stats
Suggests: testthat
NeedsCompilation: no
Packaged: 2019-04-27 15:27:17 UTC; carlosperezcarmona
Packaged: 2020-02-12 14:52:29 UTC; c.p.carmona
Repository: CRAN
Date/Publication: 2019-04-27 16:10:03 UTC
Date/Publication: 2020-02-12 15:20:05 UTC
6 changes: 3 additions & 3 deletions MD5
@@ -1,6 +1,6 @@
a15b58fdd7f7dc1782cf3b8576fd06e6 *DESCRIPTION
08c858ef5eef2949d6cdf60d11802305 *DESCRIPTION
817d6a403e94463dd4df5afba9ebc71b *NAMESPACE
045ed726fdced75a5c89be1dba9cfefe *R/DarkDiv.R
d1e63cd5cf99f1fbef10a6342fbd53c0 *R/utility_functions.R
d4bbed99767212586a534d0e94d708b2 *R/utility_functions.R
74f12839f852716c0b3b28c10148c4d8 *man/DarkDiv.Rd
70f2dc536da264419a13c1c3e28f2926 *tests/testthat.R
446ee71fe36d37609acaf68961eced81 *tests/testthat/testthat.R
2 changes: 1 addition & 1 deletion R/utility_functions.R
Expand Up @@ -111,7 +111,7 @@ BealsThres <- function(Beals, limit = NULL, const = 0.01, r, x){
## thresholds for each specis
q <- numeric(ncol(r))
t <- Beals$t
b <- Beals$rawBealsPool
b <- Beals$Pool
for (j in 1:ncol(r)){
q[j] <- 1
if (limit == "min" & sum(r[, j]) > 0){
Expand Down
78 changes: 39 additions & 39 deletions tests/testthat.R → tests/testthat/testthat.R
@@ -1,39 +1,39 @@
library(testthat)
library(DarkDiv)

test_that("Beals gives same results as vegan", {
require(vegan)
data(dune)
BealsDD <- DarkDiv(x = dune, method = "RawBeals")
BealsVegan <- vegan::beals(x = dune, type = 0, include=F)
expect_equal(BealsDD$AllProbs, BealsVegan)
})

test_that("Using indication matrix directly yields same results as reference", {
require(vegan)
data(dune)
#RawBeals
ddBeals <- DarkDiv(x = dune, method = "RawBeals")
ddBeals2 <- DarkDiv(x = dune, r = ddBeals$indication, method = "RawBeals")
expect_equal(ddBeals, ddBeals2)
#Favorability
ddFav <- DarkDiv(x = dune, method = "Favorability")
ddFav2 <- DarkDiv(x = dune, r = ddFav$indication, method = "Favorability")
expect_equal(ddFav, ddFav2)
#Hypergeometric
ddHyp <- DarkDiv(x = dune, method = "Hypergeometric")
ddHyp2 <- DarkDiv(x = dune, r = ddHyp$indication, method = "Hypergeometric")
expect_equal(ddHyp, ddHyp2)
})

test_that("When removeAbsent = F, names of species and sites are unchanged, even if some species are removed", {
require(vegan)
data(dune)
dune2 <- dune
dune2[ , 2] <- rep(0, nrow(dune2))
#RawBeals
ddHypFull <- DarkDiv(x = dune, method = "Hypergeometric")
ddHypPart <- DarkDiv(x = dune2, method = "Hypergeometric", removeAbsent = F)
expect_equal(dimnames(ddHypFull$AllProbs), dimnames(ddHypPart$Pool))
})

library(testthat)
library(DarkDiv)

test_that("Beals gives same results as vegan", {
require(vegan)
data(dune)
BealsDD <- DarkDiv(x = dune, method = "RawBeals")
BealsVegan <- vegan::beals(x = dune, type = 0, include=F)
expect_equal(BealsDD$AllProbs, BealsVegan)
})

test_that("Using indication matrix directly yields same results as reference", {
require(vegan)
data(dune)
#RawBeals
ddBeals <- DarkDiv(x = dune, method = "RawBeals")
ddBeals2 <- DarkDiv(x = dune, r = ddBeals$indication, method = "RawBeals")
expect_equal(ddBeals, ddBeals2)
#Favorability
ddFav <- DarkDiv(x = dune, method = "Favorability")
ddFav2 <- DarkDiv(x = dune, r = ddFav$indication, method = "Favorability")
expect_equal(ddFav, ddFav2)
#Hypergeometric
ddHyp <- DarkDiv(x = dune, method = "Hypergeometric")
ddHyp2 <- DarkDiv(x = dune, r = ddHyp$indication, method = "Hypergeometric")
expect_equal(ddHyp, ddHyp2)
})

test_that("When removeAbsent = F, names of species and sites are unchanged, even if some species are removed", {
require(vegan)
data(dune)
dune2 <- dune
dune2[ , 2] <- rep(0, nrow(dune2))
#RawBeals
ddHypFull <- DarkDiv(x = dune, method = "Hypergeometric")
ddHypPart <- DarkDiv(x = dune2, method = "Hypergeometric", removeAbsent = F)
expect_equal(dimnames(ddHypFull$AllProbs), dimnames(ddHypPart$Pool))
})

0 comments on commit 0aa0607

Please sign in to comment.