mace
mace

Reputation: 508

Ordihull label with single occurrence

I would like to plot goups for my ordination using the function ordihull in vegan. However I have some sites with only one occurence. Using ordihull this sites do not appear in the plot. See the example below, when only one site has BF as management. What I would like to have is a BF label where the one remaining BF management site is located in the ordination plot.

library(vegan)
data(dune)
data(dune.env)

#remove all but one row with BF as management
dune <- dune[-c(2,11),]
dune.env <- dune.env[-c(2,11),]

mod <- cca(dune ~ Management, dune.env)
attach(dune.env)
plot(mod, type="n", scaling = 3)
pl <- ordihull(mod, Management, scaling = 3, label = TRUE)

Upvotes: 0

Views: 723

Answers (1)

Gavin Simpson
Gavin Simpson

Reputation: 174853

orihull ignores groups with a single observation and thus doesn't populate the group centroids object with the centre of the convex hull. You could argue it should; I'll need to take this up with Jari and see if we can fix this.

To solve the problem, you have to add the location of the single observation in a secondary step using the text() method. [With the correct removal of all bar one of the BF observations -- -c(2,11)] the following does what you want:

plot(mod, type="n", scaling = 3)
with(dune.env, ordihull(mod, Management, scaling = 3, label = TRUE))
with(dune.env,
     text(mod, labels = Management, select = Management == "BF",
          scaling = 3, display = "sites"))

Giving

enter image description here

This is made trivial because you can specify select to choose to plot on the one observation with Management == "BF".

Upvotes: 1

Related Questions