0

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)
Cœur
  • 37,241
  • 25
  • 195
  • 267
mace
  • 490
  • 1
  • 7
  • 24

1 Answers1

1

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".

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453
  • There is nothing to draw for one-point hulls (a dimensionless point) -- or in one-point ellipses. The labels are a later addition, and we don't label hulls or ellipses that were not drawn. We do draw labels in one-point `ordispider`, and probably we should do so also in `ordihull` and `ordiellipse`. This needs some care, and a few lines of code, though. – Jari Oksanen May 28 '15 at 17:52
  • @JariOksanen Indeed, but instead of only assigning something to `cntrs` if a group contains more than 1 observation, we could just as easily fill in `cntrs` with the data point; arguably it's convex hull is an infinitely-small point at the data coordinates. I was going to open an issue on github to discuss this. This is not a Bug but we could look at this as an Enhancement. – Gavin Simpson May 28 '15 at 17:55
  • clearly this is an enhancement and should be opened up as an issue in github. – Jari Oksanen May 28 '15 at 18:13
  • pull request https://github.com/vegandevs/vegan/pull/118 gives a simple & dirty solution to the issue: it labels one-point `ordihull` and `ordiellipse` classes, but does not draw those dimensionless hulls or ellipses. – Jari Oksanen May 28 '15 at 19:15