[R-sig-eco] Sites names with spaces in ordiplot

Gavin Simpson gavin.simpson at ucl.ac.uk
Fri Apr 1 11:16:03 CEST 2011


On Fri, 2011-04-01 at 07:01 +0300, Jari Oksanen wrote:
> On 31/03/11 23:18 PM, "Manuel Spínola" <mspinola10 at gmail.com> wrote:
> 
> > Dear list members,
> > 
> > I would like to include sites names with blank spaces in an ordiplot for
> > an nmds (in vegan).
> > How I do that?
> > 
> Manuel,
> 
> Like Gav wrote, R indeed is a bit patronizing and doesn't let you to use
> dimension names with blank.

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

>  R only wants to protect you from trouble.

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

> However, vegan lets you use any names in text() function for metaMDS: just
> list those names as a vector of quoted text in 'labels' argument to
> text.metaMDS(). The names given in 'labels' can have blanks, or even be al
> blanks as long as they are quoted. The length of the 'labels' must match the
> number of items plotted.
> 
> All vegan text() functions for ordination plots should have the 'labels'
> argument. I cannot guarantee that all of them have, but you can always
> report missing cases to us. The text() for metaMDS() certainly has 'labels'
> as you can see if you read the help page ?metaMDS (which may not be a bad
> idea).
> 
> Cheers, Jari Oksanen
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-sig-ecology mailing list