rarrayslistinext

Converting matrix data frame to a list but I can't the same entry data to iNEXT


I am trying to convert a matrix data frame like this (lowland):

     species DT1 DT3 DT6 DT7 DT12 DT13 DT14 DT15 DT28 DT29
1  M_vaccinifolia   0   0   0   0    0    0    1    0    0    1
2  M_vaccinifolia   0   0   0   0    0    0    0    0    0    1
3  M_vaccinifolia   0   0   0   0    0    0    0    0    0    1
4  M_vaccinifolia   0   0   0   0    0    0    0    0    0    1
5  M_vaccinifolia   0   0   0   0    0    0    0    0    0    1
6  M_vaccinifolia   0   0   0   0    0    0    0    0    0    1
7  M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
8  M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
9  M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
10 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
11 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
12 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
13 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
14 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
15 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
16 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
17 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
18 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
19 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
20 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
21 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
22 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
23 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0
24 M_vaccinifolia   0   0   0   0    0    0    0    0    0    0

And I want to transform to a list that I can enter the data as the iNEXT data "ciliates" list is used to perform the examples in the rarefaction curves (example in the section "RAW INCIDENCE DATA FUNCTION: incidence_raw" in this link: https://cran.r-project.org/web/packages/iNEXT/vignettes/Introduction.html. Below is how the list is interpreted:

 command
str(ciliates$EtoshaPan)


int [1:365, 1:19] 0 0 0 0 0 0 0 0 0 0 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:365] "Acaryophrya.collaris" "Actinobolina.multinucleata.n..sp." "Afroamphisiella.multinucleata.n..sp." "Afrothrix.multinucleata.n..sp." ...
  ..$ : chr [1:19] "x53" "x54" "x55" "x56" ...

When I convert my data lowland, I just can reach this kind of list

     lowland_list <- list(lowland)
    str(lowland_list)



    List of 1
 $ :'data.frame':   24 obs. of  11 variables:
  ..$ species: chr [1:24] "M_vaccinifolia" "M_vaccinifolia" "M_vaccinifolia" "M_vaccinifolia" ...
  ..$ DT1    : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DT3    : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DT6    : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DT7    : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DT12   : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DT13   : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DT14   : int [1:24] 1 0 0 0 0 0 0 0 0 0 ...
  ..$ DT15   : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DT28   : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
  ..$ DT29   : int [1:24] 1 1 1 1 1 1 0 0 0 0 ...

What is not a proper entry data format to iNEXT read as the example. I spent many hours trying to make a list to enter this data but I couldn't figure it out. How can I do this?


Solution

  • Not sure if this helps, but I have 2 data.frames that are in species columns and sites rows (datA and datB). Here's some example code.

    make an empty list:

    datlist <- list()
    datlist$A <- data.frame(t(datA))
    datlist$B <- data.frame(t(datB))
    

    then run iNEXT

    iNEXT(datlist
          , q = c(0, 1, 2)
          , "incidence_raw"
          , conf = 0.95
          , se = TRUE
          , knots = 200
          , nboot = 200
          )