biometry / bipartite

repository for the bipartite R-package for network analysis
37 stars 17 forks source link

Issue using H2fun() #11

Closed sjdritz closed 4 years ago

sjdritz commented 4 years ago

I am running H2fun() of the 'bipartite' class in R studio using R version 3.6.1.

Inputting a 20x20 matrix of non-integers where the values is each column sum to 1, it appears that when I run this function with H2_integer set to false, H2_max is never defined before the comparison with H2_max.improved is performed

The error message is:

Error in ifelse(H2_max >= H2_max.improved, H2_max, H2_max.improved) : object 'H2_max' not found

Looking at the source code it appears that the line:

H2_max <- -sum(newweb/tot*log(newweb/tot), na.rm=TRUE) # first attempt of finding H2_max

only executes in the else block where H2_integer is TRUE.

JochenFruend commented 4 years ago

Thanks for reporting. I think I've fixed it on github.