User Tools

Site Tools


en:customized_functions:ordicenter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:customized_functions:ordicenter [2016/06/04 22:33]
David Zelený
en:customized_functions:ordicenter [2017/10/11 20:36]
Line 1: Line 1:
-====== ordicenter ====== 
- 
-**Author: David Zelený** 
- 
-Function which adds group centroids onto ordination diagram. The code heavily borrows from the ''vegan'' function ''ordispider'', written by Jari Oksanen. Use of ''ordicenter'' (including the names of its arguments) has the same logic (for details about the arguments and use, consult help to ''ordispider'' function). 
- 
-See [[en:indirect_ordination_viz#ordicenter_custom_function|here]] for examples how to use this function. 
- 
-<file ordicenter.r> 
-ordicenter <- function (ord, groups, display = "sites", w = weights(ord, display),  
-            show.groups, ...)  
-  { 
-    weights.default <- function(object, ...) NULL 
-    pts <- scores(ord, display = display, ...) 
-    w <- eval(w) 
-    if (length(w) == 1)  
-      w <- rep(1, nrow(pts)) 
-    if (is.null(w))  
-      w <- rep(1, nrow(pts)) 
-    if (!missing(show.groups))  
-    { 
-      take <- groups %in% show.groups 
-      pts <- pts[take, , drop = FALSE] 
-      groups <- groups[take] 
-      w <- w[take] 
-    } 
-    out <- seq(along = groups) 
-    inds <- names(table(groups)) 
-    for (is in inds)  
-    { 
-      gr <- out[groups == is] 
-      if (length(gr) > 1) 
-      { 
-        X <- pts[gr, ] 
-        W <- w[gr] 
-        ave <- apply(X, 2, weighted.mean, w = W) 
-        vegan:::ordiArgAbsorber(ave[1], ave[2], labels = is, FUN = text, ...) 
-      } 
-      if (length(gr) == 1) 
-      { 
-        X <- pts[gr, ] 
-        W <- w[gr] 
-        vegan:::ordiArgAbsorber(X[1], X[2], labels = is, FUN = text, ...) 
-      } 
-    } 
-    invisible() 
-  } 
-</file> 
  
en/customized_functions/ordicenter.txt · Last modified: 2017/10/11 20:36 (external edit)