Skip to content

Instantly share code, notes, and snippets.

@zkamvar
Last active December 27, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zkamvar/7346882 to your computer and use it in GitHub Desktop.
Save zkamvar/7346882 to your computer and use it in GitHub Desktop.
Polymorphic Information Content
pic <- function(gid){
if (gid@type != "PA"){
gid_loc <- seploc(gid)
return(vapply(gid_loc, pic_loc, 1))
}
else{
return(vapply(1:nLoc(gid), function(x) pic_loc(gid[, x]), 1))
}
}
pic_loc <- function(gid_loc){
return(1 - sum((colSums(gid_loc@tab, na.rm = TRUE)/nInd(gid_loc))^2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment