Git Product home page Git Product logo

Comments (1)

Rekyt avatar Rekyt commented on June 12, 2024

Reprex:

library(funrar)

trait_df = data.frame(tr1 = c("A", "A", "B", "B"), tr2 = c(rep(0, 3), 1),
                      tr3 = seq(4, 16, 4))

rownames(trait_df) = letters[1:4]

# Distance Matrix
dist_mat = compute_dist_matrix(trait_df)

small_mat = matrix(c(1, 0, 0, 1), nrow = 2)
colnames(small_mat) = letters[1:2]
rownames(small_mat) = c("s1", "s2")

small_df = matrix_to_stack(small_mat)

# Warning
distinctiveness(small_mat, dist_mat)
#> Distance matrix bigger than site-species matrix
#> Taking subset of distance matrix
#> Warning in distinctiveness(small_mat, dist_mat): Some communities had a single species in them
#> Computed value assigned to 'NaN'
#>      a   b
#> s1 NaN  NA
#> s2  NA NaN

# No warning + computes distinctiveness for absent species
distinctiveness_stack(small_df, "col", "row", "value", dist_mat)
#> More species in distance matrix than in community data.frame
#> Taking subset of distance matrix
#>   col row value        Di
#> 1   a  s1     1       NaN
#> 2   b  s1     0 0.1111111
#> 3   a  s2     0 0.1111111
#> 4   b  s2     1       NaN

Should add tests to expect warnings + undefined distinctiveness for species that are absent.

from funrar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.