Skip to content

Instantly share code, notes, and snippets.

library(entropy)
library(ggplot2)
olaps <- function(sp1, sp2){
sp1 <- sp1/sum(sp1)
sp2 <- sp2/sum(sp2)
plot.table <- data.frame(species = c(rep("sp1", length(sp1)), rep("sp2", length(sp2))),
env = c(seq(1:length(sp1)), seq(1:length(sp2))),
@danlwarren
danlwarren / thin.max.R
Last active May 20, 2024 15:43
thin.max.R, a function for rarefying point data in any number of dimensions
# Function to rarefy point data in any number of dimensions. The goal here is to
# take a large data set and reduce it in size in such a way as to approximately maximize the
# difference between points. For instance, if you have 2000 points but suspect a lot of
# spatial autocorrelation between them, you can pass in your data frame, the names (or indices)
# of the lat/lon columns, and the number 200, and you get back 200 points from your original data
# set that are chosen to be as different from each other as possible given a randomly chosen
# starting point
# Input is:
#