BiologicalRecordsCentre / sparta

Species Presence/Absence R Trends Analyses
http://biologicalrecordscentre.github.io/sparta/index.html
MIT License
21 stars 24 forks source link

Community similarity in Frescalo #187

Open AGAuffret opened 4 years ago

AGAuffret commented 4 years ago

Hello, I was interested in trying to use community similarity (rather than environmental similarity) for creating the site weights for the Frescalo analysis, as Hill (2012) does. I implemented it locally quite simply in the createWeights() function, first adding an argument to the function choosing the similarity method (with Euclidean as default to preserve current functionality):

createWeights<-function (distances, attributes, sim_method="euclidean", dist_sub = 200, sim_sub = 100, normalise = FALSE)

Then replacing the current method using the dist() function with vegan's vegdist():

sim_distance <- vegdist(attributes[, 2:length(names(attributes))], method=sim_method, diag=TRUE, upper=TRUE)

I also added a relevant check to errorChecks() regarding choice of distance function, and I guess vegan would need to be added to the dependent packages.

Is this something useful enough that you might be interested in implementing into the package? If I can manage to work out how to do pull requests properly then I'm happy to try it, but I'm also open to you maintainers doing it yourselves.

Thanks, Alistair