0

I am trying to make a biplot in R using the vegan package:

shared_tbl <-read_tsv("data/andok.shared")

my data is like this table:

Group Blastocatellales Frankiales Cyanobacteriales
sample1 319 2563 546
sample2 4114 657 986
sample3 1463 123 85
sample4 158 367 631
shared_df <- shared_tbl%>%
   column_to_rownames("Group")

#make a distance matrix
andok_dist <- avgdist(shared_df, sample = 1156)

#nmds ordination
set.seed(1996020)
andok_nmds <- metaMDS(andok_dist)
scores(andok_nmds)

and then I got the error: Error in x$species[, choices, drop = FALSE] : incorrect number of dimensions

A solution has reached in metaMDS after setting the seed.

I made my steps according to Pat Schloss https://www.youtube.com/watch?v=_EjNR6YdnGM&t=45s%5C half years ago, when the whole code ran without any errors.

vicey
  • 13
  • 3
  • Try to create a reproducible example so we can help you. See: https://stackoverflow.com/help/minimal-reproducible-example – megmac Jan 03 '23 at 21:46
  • I added a table similar to mine, thank you for your comment! :) – vicey Jan 03 '23 at 22:32
  • which line is the one giving you a problem? Your code works with my dummy data I created. – megmac Jan 04 '23 at 00:11
  • After scores(andok_nmds) I got an error: Error in x$species[, choices, drop = FALSE] : incorrect number of dimensions – vicey Jan 04 '23 at 08:51

1 Answers1

1

This error may occur in vegan 2.6-2. It was fixed in the latest release version 2.6-4. Please upgrade your vegan. If you cannot or will not upgrade vegan, explicitly skip species scores (that you do not have when input data are dissimilarities which have no information on species):

scores(andok_mds, display="sites")

The problems was introduced when the scores function gained option of directly producing "tidy" scores for ggplot2 graphics.

Jari Oksanen
  • 3,287
  • 1
  • 11
  • 15