Skip to content
Prev 2022 / 7420 Next

Sites names with spaces in ordiplot

On Fri, 2011-04-01 at 07:01 +0300, Jari Oksanen wrote:
It does. I made the species labels in my examples *not* have spaces in
them because Manuel said only his site names had spaces. The following
works just fine:

require(vegan)
set.seed(1)
dat <- data.frame(matrix(runif(100), ncol = 10))
names(dat) <- paste("Spp", 1:10)
rownames(dat) <- paste("Site", 1:10)
mod <- metaMDS(dat)
plot(mod, type = "text")
Indeed - it is a pain to look at `Spp 1` now, for example, as everything
needs to be quoted:

R> dat$`Spp 1`
 [1] 0.26550866 0.37212390 0.57285336 0.90820779 0.20168193 0.89838968
 [7] 0.94467527 0.66079779 0.62911404 0.06178627

One issue that might catch people out is that R doesn't let you read
data in with spaces in the colnames (unless read.table()'s check.names =
FALSE is set) - spaces get replaced with `.`.

However, the only constraint on rownames is that they be non-missing and
non-duplicated. Both sets of names need to be syntactically valid but
spaces are fine.

Hence one can always change the row/colnames to suit just before
plotting so one doesn't need to resort to extra plotting calls to
achieve the desired result. That said, one usually will need extra calls
to ordiplot functions as ordinations are complex beasts to plot so
drawing the points with custom text labels is no real hardship either.

Either approach works.

G