5

ANSWERED: A single NA value in any column in either data.frame can cause this error.


I have a rather frustrating problem that I need help with. I'm trying to run a permanova in R, and I'm using adonis() in Vegan to do it. I have a species by sample data.frame, 249 rows by 16 columns (species names as column.names), and a separate data.frame of 249 rows by 3 columns, containing my environmental covariates. I'm using the code below to run it, and I get the error above. I've run adonis on some very, very similar data without issue, and I'm not sure what's wrong this time through.

Any suggestions? Thanks a ton.


Code

SpeciesADONIS <- adonis(ScreenedSpeciesbySample ~ AvgSalinity + AvgTurbidity +
        AvgDO + AvgSalinity * AvgTurbidity + AvgSalinity*AvgDO + 
        AvgTurbidity * AvgDO,
    data = RegPhysDriversTimeSeries2,
    permutations=999, method="bray")

Species by Sample head (created using dput)

ScreenedSpeciesbySample <- 
    structure(list(
        "Gulf menhaden" = c(0.05, 0.05, 0.01, 0.02, 0.00471, 0.01), 
        "Hardhead catfish" = c(0, 0, 0, 0.26, 0.00107, 0.04), 
        "White shrimp" = c(0.00298, 9.2e-06, 0.04, 0.13, 0.36, 0.01), 
        "Atlantic croaker" = c(0.01, 0.14, 0.44, 0.25, 0.08, 0.05), 
        "Black drum" = c(0, 0, 0, 0.12, 0, 0), 
        "Gafftopsail catfish" = c(0, 0, 0, 0, 0, 0), 
        "Striped mullet" = c(0.46, 0, 0, 0, 0, 0), 
        "Brown shrimp" = c(0, 0, 0, 0, 0.32, 0.04), 
        "Spotted seatrout" = c(0, 0, 0, 0, 0, 0), 
        "Spot" = c(0.11, 0.41, 3.02e-05, 0.02, 0.00021, 0.00271), 
        "Gizzard shad" = c(0, 0.17, 0, 0, 0, 0), 
        "Red drum" = c(0, 0, 0, 0, 0, 0), 
        "Bay anchovy" = c(0.00164, 0, 0, 0, 0.000127, 8.84e-05), 
        "Atlantic cutlassfish" = c(0, 0, 0, 0, 0.01, 0.49), 
        "Sand seatrout" = c(0, 0, 0, 0.04, 0.03, 0), 
        "Blue crab" = c(494.27, 583.35, 705.43, 476.09, 3103.18, 1699.67)), 
        .Names = c("Gulf menhaden", 
            "Hardhead catfish", "White shrimp", "Atlantic croaker", "Black drum", 
            "Gafftopsail catfish", "Striped mullet", "Brown shrimp", "Spotted seatrout", 
            "Spot", "Gizzard shad", "Red drum", "Bay anchovy", "Atlantic cutlassfish", 
            "Sand seatrout", "Blue crab"), 
        row.names = c(NA, 6L), 
        class = "data.frame")

Physical covariates head (created using dput)

RegPhysDriversTimeSeries2 <- 
    structure(list(
      AvgSalinity = c(14.88, 14.84, 5.7, 4.8, 9.5, 11.41), 
      AvgTurbidity = c(29.5, 53.53, 109.71, 109.48, 73.69, 39.37), 
      AvgDO = c(11.19, 8.18, 8.37, 14.39, 10.61, 7.94)),
      .Names = c("AvgSalinity", "AvgTurbidity", "AvgDO"), 
      row.names = c(NA, 6L),
      class = "data.frame")
FishyStats
  • 71
  • 4
  • 7
  • I can't replicate your problem, perhaps because your first data frame is missing some numbers for the first species (I just filled in some random values, and `adonis` ran fine). Generally the error you report would occur when the matrix containing your covariates, and the matrix containing your species have different numbers of rows. Make sure this isn't the case. – Nate Pope Sep 16 '13 at 20:09
  • 1
    Mea culpa, I fixed the code in my example. I have checked using both length(ScreenedSpeciesbySample[,x]) and the data descriptions in the RStudio workspace. Both methods show me that both the drivers and species data.frame have 249 rows. I'm at a loss for why this error is coming up. – FishyStats Sep 16 '13 at 23:54
  • Not reproducible with the snippet of data you included. Does it work for you with the snippet of data or is it an issue only with the larger set? – Gavin Simpson Sep 17 '13 at 03:05
  • 1
    I just ran the exact same adonis using the snippets I sent, and it runs. I'm genuinely confused now. Should I include both full tables? I'm hesitant to spam that many lines onto this page. Suggestions for how I can find a solution to this issue would be much appreciated. Thank you all very much for all your help so far. – FishyStats Sep 17 '13 at 14:17
  • In the full data set, are there missing values in either the covariate or species matrices that would cause a row to be dropped, when they are input into `adonis`? – Nate Pope Sep 17 '13 at 15:56
  • 1
    There was a single NA value in row 217 of my physical covariate matrix. The adonis() function is running now. If we're ever at a conference together or you find yourself in Miami, I most definitely owe you a drink. – FishyStats Sep 17 '13 at 16:29

0 Answers0