rerror-handlingmds

Error in FUN(X[[i]], ...) : only defined on a data frame with all numeric variables in running a MDS in vegan


Hello I am trying to run an MDS to create a plot these are my data

                 A       B     C      D
B_2016           54.67  3.67    10    1
Emb_2016           37.67    10.33   1.67    10.33
Fes_2016           19.33    32.67   2.67    2.33
Ku_2016          0       5.33   1.67    28.33
Ra_2016          6      20.33   11.33   29.33
Ud_2016          8       5.33   1.33    4.33
Ve _2016           84.67     4.67   1       21
Ba _2017         0       3    2     6.97
Emb _2017          0         4    2.77  4.47
Fes_2017           0         0.01   0       0
Ku_2017          0       0.1    0.02    0.16
Ra_2017          0       0    1     11
Ud_2017          0       5    3     4
Ve_2017          0       0    0     0

AND THIS IS MY CODE

mds<-metaMDS(macnally, k=2, distance="bray", autotransform=FALSE, trymax=100)

But I get this error:

Error in FUN(X[[i]], ...) : only defined on a data frame with all numeric variables In addition: Warning message: In Ops.factor(left, right) : ‘<’ not meaningful for factors

Could help me so I can then plot it? Thank you so much


Solution

  • There are spaces in your row names for Ve_2016, Ba_2017 and Emb_2017 which may be giving you an error message.

    library(vegan)
    
    A <- c(54.67, 37.67, 19.33, 0, 6, 8, 84.67, 0,0,0,0,0,0,0)
    B <- c(3.67, 10.33, 32.67, 5.33, 20.33, 5.33, 4.67, 3, 4, 0.01, 0.1, 0, 5, 0)
    C <- c(10, 1.67, 2.67, 1.67, 11.33, 1.33, 1, 2, 2.77, 0, 0.02, 1,3,0)
    D <- c(1,10.33, 2.33, 28.33, 29.33, 4.33, 21, 6.97, 4.47, 0, 0.16, 11, 4,0)
    df <- cbind(A,B,C,D)
    
    row.names(df) <- c('B_2016', 'Emb_2016', 'Fes_2016', 'Ku_2016', 'Ra_2016', 'Ud_2016',
      'Ve_2016', 'Ba_2017', 'Emb_2017', 'Fes_2017', 'Ku_2017', 'Ra_2017',
      'Ud_2017', 'Ve_2017')
    
    mds <- metaMDS(df, distance='bray')
    
    plot(mds)