Search code examples
rpcavegan

RDA analysis in R gives error "attempt to set an attribute on NULL"


I'm running an analysis in R with the Vegan package. It's really simple in the way that I only want the summary to extract some values. But it keeps telling me an error message. Why?

I have this dataset

feed.raw1 =structure(c(0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
            5L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 7L, 11L, 3L, 1L, 
            0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 
            0L, 0L, 0L, 0L, 3L, 0L, 5L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
            0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 8L, 7L, 5L, 1L, 
            0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 10L, 5L, 0L, 0L, 1L, 0L, 0L, 
            0L, 0L, 0L, 0L, 0L, 1L, 5L, 0L, 0L, 8L, 9L, 0L, 0L, 5L, 0L, 0L, 
            0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 15L, 0L, 
            51L, 10L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 
            0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 3L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 
            0L, 0L, 0L, 45L, 203L, 17L, 54L, 4L, 1L, 0L, 0L, 0L, 0L, 10L, 
            9L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 12L, 0L, 
            0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 22L, 206L, 9L, 16L, 1L, 
            1L, 6L, 6L, 0L, 0L, 4L, 5L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
            0L, 7L, 0L, 0L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
            2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 12L, 3L, 1L, 0L, 
            0L, 0L, 0L, 0L, 0L, 0L, 23L, 4L, 1L, 2L, 0L, 2L, 0L, 0L, 0L, 
            0L, 0L, 0L, 0L, 0L, 76L, 0L, 96L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 
            11L, 0L, 3L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 270L, 
            144L, 7L, 8L, 15L, 6L, 6L, 2L, 6L, 1L, 25L, 5L, 0L, 1L, 1L, 0L, 
            0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 14L, 2L, 1L, 0L, 0L, 0L, 0L, 
            0L, 3L, 0L, 0L, 0L, 3L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
            0L, 2L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 1L, 0L, 
            0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 7L, 0L, 0L, 0L, 0L, 0L, 
            0L, 14L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 
            0L, 0L), .Dim = c(12L, 32L), .Dimnames = list(c("a", "b", "c", 
                                                            "d", "e", "f", "g", "h", "i", "j", "k", "l"), c("a", "b", "c", 
                                                                                                            "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", 
                                                                                                            "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "a1", "b1", 
                                                                                                            "c1", "d1", "e1", "f1")))

And I'm running this analysis:

library(vegan)
feed_raw.hel = decostand(feed.raw1, method = "pa")

pca.feed=vegan::rda(feed_raw.hel, scale=FALSE) 
head(summary(pca.feed))

It gives me this error:

Canonical correspondence analysis

Class: rda cca
Call: rda(X = feed_raw.hel, scale = FALSE)

Total inertia: 0

Eigenvalues:
Error in names(vec) <- paste("Ax", 1:length(vec), sep = "") : 
  attempt to set an attribute on NULL

Solution

  • No error found (see comments in the OP):

    > library(vegan)
    > feed_raw.hel = decostand(feed.raw1, method = "pa")
    >
    > pca.feed=vegan::rda(feed_raw.hel, scale=FALSE)
    > head(summary(pca.feed))
    
    Call:
    rda(X = feed_raw.hel, scale = FALSE)
    
    Partitioning of variance:
                  Inertia Proportion
    Total           5.394          1
    Unconstrained   5.394          1
    
    Eigenvalues, and their contribution to the variance
    
    Importance of components:
                             PC1    PC2    PC3    PC4     PC5     PC6     PC7
    Eigenvalue            2.0696 0.7676 0.6639 0.5502 0.41578 0.31941 0.22209
    Proportion Explained  0.3837 0.1423 0.1231 0.1020 0.07708 0.05922 0.04117
    Cumulative Proportion 0.3837 0.5260 0.6491 0.7511 0.82817 0.88739 0.92856
                              PC8     PC9    PC10    PC11
    Eigenvalue            0.15383 0.11310 0.07857 0.03984
    Proportion Explained  0.02852 0.02097 0.01457 0.00739
    Cumulative Proportion 0.95708 0.97805 0.99261 1.00000
    
    Scaling 2 for species and site scores
    * Species are scaled proportional to eigenvalues
    * Sites are unscaled: weighted dispersion equal on all dimensions
    * General scaling constant of scores:  2.775394
    
    
    Species scores
    
              PC1      PC2      PC3      PC4        PC5      PC6
    a    -0.03289 -0.13245  0.18066  0.12616 -0.2028751  0.07257
    b    -0.19170 -0.26686 -0.20142 -0.16621  0.0739356 -0.16726
    c    -0.43542 -0.24013 -0.02194  0.16668 -0.0037653  0.18018
    d    -0.43702  0.08614 -0.05548 -0.06814 -0.0009418 -0.03947
    e    -0.24815 -0.06070  0.29795  0.18439 -0.0879021 -0.02246
    f     0.08852  0.11597 -0.07947  0.02250 -0.0926734 -0.13060
    ....                                                    
    
    
    Site scores (weighted sums of species scores)
    
              PC1      PC2      PC3     PC4     PC5     PC6
    a    -1.65813  0.55267  0.90341  0.4485  0.8856 -0.7321
    b    -1.70818  0.11084 -1.33080 -0.9734 -0.8929  0.4280
    c    -0.25333 -1.02024  1.39160  0.9718 -1.5627  0.5590
    d    -0.09478 -1.47685 -1.03494  1.1078  1.2228 -0.2536
    e     0.26417  0.60502  0.71856 -0.6194  1.1614  1.2200
    f     0.36048 -0.01608 -0.09826 -0.2709  0.3182  1.3866
    ....