'permanova betadisper: missing observations due to 'group' removed Error in eigen(-x/2, symmetric = TRUE) : 0 x 0 matrix

I tried to adapt a code from an earlier version of R to process some data. I got most of it working again but ran into an issue.... I am trying to use vegan to run a permanova and permdisp, however when I get to the betadisper part I get the error "missing observations due to 'group' removed Error in eigen(-x/2, symmetric = TRUE) : 0 x 0 matrix" I am not the best at R.... but I have tried to futz with it and don't know where I went wrong....

Thank you for reading and any Help would be appreciated.

require (vegan)
require (ggplot2)
require (gridExtra)
require (pals)
require (ape)
require (RColorBrewer)



legpro<- read.table('legpro.txt', sep='\t', header=T,row.names = 1)

legpro.std<-legpro[,3:ncol(legpro)]/legpro$Overall.body.Size.Estimator

legpro.std<-cbind(legpro$Code,legpro.std)
names(legpro.std)[1]<- 'Code'
legpro.std<-cbind(legpro$Species.Name,legpro.std)
names(legpro.std)[1]<- 'Species.Name'
#legpro.std<-legpro.std[-54] 
#excluding body size from data
legpro.std<-legpro.std[-54]
#-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17,-21,-22,-23,-29,-35,-41,-45,-46,-48,-49,-51,-52, can eliminate

head(legpro.std)
tail(legpro.std)

plot(legpro.std$claw1,legpro.std$claw2)
plot(legpro.std$claw1,legpro.std$claw3)
plot(legpro.std$Forewing.width,legpro.std$Forewing.length)
plot(legpro$Overall.body.Size.Estimator,legpro$Forewing.length)

legpro.std$Code <- factor(legpro.std$Code,levels = c('A.adnixa','A.modesta','A.bicolor','A.plomleyi','C.rastricornis','S.itasca','S.mohri','C.fitchi','C.simplicior','S.flinti','S.vicaria','C.areolaris','O.fulvicephalus','D.macleodi','N.americanus','D.binocula','H.costalis','H.stigma','S.angustus','M.tasmaniae','L.banksi','L.squamosa','S.pavida','D.sayi','C.tenuistriga','C.cincta','A.eureka','C.collaris','P.prasinus','C.coloradensis','N.myrmeleonoides','A.occidens','P.capicola','P.immensus','P.libelluloides','U.macleayanus','U.floridanus','U.quadripunctatus','U.bicolor','L.longicornis','L.coccajus','D.speciosus','C.pusillus','B.mexicanus','B.californicus','B.abdominalis','C.abdominalis','C.schwarzi','M.trigrammus','M.californicus','M.exitialis','P.hageni','V.fallax','S.carrizonus','S.dissimilis','S.eiseni','B.furcatus','B.lethalis','E.sinuatum','E.ornatum','E.arizonense','G.luniger','M.bilineatus','C.plumbeus','D.tetragrammicus'))#for setting species order

###Permanova

permanova<-adonis2(log10(legpro.std[,3:ncol(legpro.std)])~legpro.std$Species.Name,method='euclidean')
permanova


###Permdisp
Name.Code<- as.factor(legpro.std$Code) 
legpro.dis<- vegdist(log10(legpro.std[,3:ncol(legpro.std)]),'euclidean')
perm.legpro <- betadisper (legpro.dis,Name.Code,type=c('median'))
perm.legpro2<- permutest(perm.legpro,pairwise=T, permutations=9999)
anova(perm.legpro)
TukeyHSD(perm.legpro)

pcoa<- pcoa(vegdist(log10(legpro.std[,3:ncol(legpro.std)]),'euclidean'))
print(pcoa)#Cumum_eig or 


pcoa.cm<-cmdscale(vegdist(log10(legpro.std[,3:ncol(legpro.std)]),'euclidean'),add = F)
print(pcoa.cm) #% explanation of each axis is given by the variance of the axis/total pcoa variance or check above

The data from head is:

head(legpro.std) Species.Name Code claw1 claw2 claw3 Totleglength1 Totleglength2 Totleglength3 Coxa1.anterior 1 Sialis.itasca.Ross 0.04570004 0.04528458 0.05359368 2.080806 2.397590 3.108226 0.3477358 2 Sialis.itasca.Ross 0.04510309 0.05111684 0.05025773 2.026632 2.348797 2.907216 0.3311856 3 Sialis.itasca.Ross 0.04593070 0.05116841 0.04472200 1.904915 2.350322 2.831184 0.2912973 4 Sialis.itasca.Ross 0.04196933 0.04237288 0.04640840 1.945924 2.228612 2.730024 0.2824859 5 Sialis.itasca.Ross 0.04725473 0.05220522 0.05445545 2.048830 2.428218 2.951395 0.3280828 6 Sialis.itasca.Ross 0.04471005 0.05046481 0.05002213 2.318504 2.488490 3.011067 0.3333333 coxa1.posterior Coxa1average Coxa2.anterior coxa2.posterior Coxa2.average Coxa3.anterior coxa3.posterior 1 0.3169921 0.3323639 0.3402576 0.3485667 0.3444121 0.2937266 0.3223930 2 0.3144330 0.3228093 0.3784364 0.3625429 0.3704897 0.2916667 0.3487972 3 0.2538275 0.2725624 0.3352135 0.3231265 0.3291700 0.2828364 0.3227236 4 0.2861178 0.2843019 0.2744149 0.2836965 0.2790557 0.2655367 0.2869250 5 0.3352835 0.3316832 0.2812781 0.3096310 0.2954546 0.2736274 0.3105311 6 0.3196104 0.3264719 0.3430721 0.3413015 0.3421868 0.3005755 0.3594511 Coxa3.average femur1 femur2 femur3 Forewing.length Forewing.width Forewingsurice.area tarsi1_1 tarsi1_2 1 0.3080598 0.5334441 0.6248442 0.7714998 3.905692 1.140839 10.72503 0.1479020 0.08516826 2 0.3202319 0.5945017 0.6224227 0.7096220 3.717354 1.240550 10.73572 0.1271478 0.08161512 3 0.3027800 0.5302175 0.6877518 0.7304593 3.708702 1.221595 11.24479 0.1373892 0.07775987 4 0.2762308 0.5145279 0.5952381 0.7094431 3.672720 1.142454 10.39747 0.1323648 0.07627119 5 0.2920792 0.5234024 0.6710172 0.7178218 3.894690 1.299730 11.24786 0.1314131 0.08190819 6 0.3300133 0.7242143 0.6573705 0.7312970 3.911022 1.100044 9.71889 0.1496237 0.08632138 tarsi1_3 tarsi1_4 tarsi1_5 tarsi1tot tarsi2_1 tarsi2_2 tarsi2_3 tarsi2_4 tarsi2_5 tarsi2tot tarsi3_1 1 0.05899460 0.03406730 0.07810552 0.4042376 0.1798920 0.09056917 0.08890735 0.03199003 0.1574574 0.5488159 0.3103448 2 0.06185567 0.03006873 0.09235395 0.3930412 0.1859966 0.12113402 0.08376288 0.03565292 0.1245704 0.5511168 0.2843643 3 0.06124093 0.02739726 0.08622079 0.3900080 0.1833199 0.11724416 0.07534246 0.03424657 0.1446414 0.5547945 0.2123288 4 0.06133979 0.02986279 0.09604520 0.3958838 0.1949153 0.10895885 0.07506054 0.02945924 0.1142050 0.5225989 0.2566586 5 0.05940594 0.02880288 0.09180918 0.3933394 0.1908191 0.10531054 0.08235824 0.03915392 0.1345635 0.5522052 0.2808281 6 0.05843293 0.03320053 0.09871625 0.4262948 0.2173528 0.12926073 0.09606020 0.03231518 0.1372289 0.6122178 0.2855246 tarsi3_2 tarsi3_3 tarsi3_4 tarsi3_5 tarsi3tot tibia1 tibia2 tibia3 Trochanter1.anterior 1 0.1458247 0.12172829 0.04154549 0.1728292 0.7922725 0.6726215 0.7349398 1.0793519 0.14291649 2 0.1658076 0.10438144 0.03651203 0.1507732 0.7418385 0.6065292 0.6808419 0.9746564 0.09879725 3 0.1305399 0.07896857 0.03505237 0.1543110 0.6112006 0.6176470 0.6458501 1.0209508 0.08944399 4 0.1513317 0.09564165 0.04317999 0.1452785 0.6920904 0.6432607 0.7171106 0.9196933 0.10290557 5 0.1588659 0.09675968 0.04095410 0.1332133 0.7106211 0.7011701 0.7803781 1.0756077 0.09315932 6 0.1651173 0.10358565 0.03497123 0.1412129 0.7304117 0.7348384 0.7290836 1.0624170 0.09517486 Trochanter1.posterior Trochanter1.average Trochanter2.anterior Trochanter2.posterior Trochanter2.average 1 0.13336103 0.13813876 0.15828833 0.1308683 0.1445783 2 0.12070446 0.10975085 0.12070446 0.1271478 0.1239261 3 0.09951651 0.09448025 0.10999194 0.1555197 0.1327558 4 0.11299435 0.10794996 0.09483455 0.1343826 0.1146086 5 0.10531054 0.09923493 0.10711072 0.1512151 0.1291629 6 0.11819388 0.10668437 0.14121292 0.1540505 0.1476317 Trochanter3.anterior Trochanter3.posterior Trochanter3.average 1 0.1819692 0.1321147 0.1570420 2 0.1503436 0.1713917 0.1608677 3 0.1651894 0.1663981 0.1657937 4 0.1315577 0.1335755 0.1325666 5 0.1480648 0.1624663 0.1552655 6 0.1460823 0.1677733 0.1569278

dput


structure(list(Species.Name = c("Sialis.itasca.Ross", "Sialis.itasca.Ross", 
"Sialis.itasca.Ross", "Sialis.itasca.Ross", "Sialis.itasca.Ross", 
"Sialis.itasca.Ross"), Code = structure(c(6L, 6L, 6L, 6L, 6L, 
6L), levels = c("A.adnixa", "A.modesta", "A.bicolor", "A.plomleyi", 
"C.rastricornis", "S.itasca", "S.mohri", "C.fitchi", "C.simplicior", 
"S.flinti", "S.vicaria", "C.areolaris", "O.fulvicephalus", "D.macleodi", 
"N.americanus", "D.binocula", "H.costalis", "H.stigma", "S.angustus", 
"M.tasmaniae", "L.banksi", "L.squamosa", "S.pavida", "D.sayi", 
"C.tenuistriga", "C.cincta", "A.eureka", "C.collaris", "P.prasinus", 
"C.coloradensis", "N.myrmeleonoides", "A.occidens", "P.capicola", 
"P.immensus", "P.libelluloides", "U.macleayanus", "U.floridanus", 
"U.quadripunctatus", "U.bicolor", "L.longicornis", "L.coccajus", 
"D.speciosus", "C.pusillus", "B.mexicanus", "B.californicus", 
"B.abdominalis", "C.abdominalis", "C.schwarzi", "M.trigrammus", 
"M.californicus", "M.exitialis", "P.hageni", "V.fallax", "S.carrizonus", 
"S.dissimilis", "S.eiseni", "B.furcatus", "B.lethalis", "E.sinuatum", 
"E.ornatum", "E.arizonense", "G.luniger", "M.bilineatus", "C.plumbeus", 
"D.tetragrammicus"), class = "factor"), claw1 = c(0.0457000398959275, 
0.045103090158027, 0.0459306989564186, 0.0419693321653473, 0.0472547265893557, 
0.0447100492179136), claw2 = c(0.045284584153096, 0.0511168382615714, 
0.051168411852526, 0.042372881410651, 0.0522052218973023, 0.050464806029534
), claw3 = c(0.0535936807297095, 0.050257730039612, 0.0447219967552032, 
0.0464083960590078, 0.0544554479373681, 0.0500221314070853), 
    Totleglength1 = c(2.080805936746, 2.02663219508693, 1.90491528797122, 
    1.94592417110508, 2.04882996069499, 2.31850370337949), Totleglength2 = c(2.3975902975308, 
    2.3487971821018, 2.35032225197969, 2.22861185065265, 2.42821795709869, 
    2.48849039363661), Totleglength3 = c(3.10822595137736, 2.90721641469161, 
    2.83118434974866, 2.7300243220427, 2.95139534984782, 3.0110667765838
    ), Coxa1.anterior = c(0.347735766263887, 0.331185569221734, 
    0.291297323563015, 0.282485879299417, 0.328082812807204, 
    0.333333333333333), coxa1.posterior = c(0.316992102366229, 
    0.314432977364315, 0.253827544849914, 0.286117841877611, 
    0.335283548106612, 0.31961043951507), Coxa1average = c(0.332363934522785, 
    0.322809273078248, 0.272562434407915, 0.28430186079029, 0.33168318068193, 
    0.326471886424202), Coxa2.anterior = c(0.340257575356567, 
    0.378436407168337, 0.335213529057563, 0.27441486170569, 0.281278142496969, 
    0.343072135629241), coxa2.posterior = c(0.348566665701357, 
    0.362542936849028, 0.323126490526473, 0.283696541563174, 
    0.309630989611699, 0.341301463699871), Coxa2.average = c(0.344412120321235, 
    0.370489672008682, 0.329170009993469, 0.279055701634432, 
    0.295454566279356, 0.342186799664556), Coxa3.anterior = c(0.293726629791346, 
    0.291666666612973, 0.282836418227029, 0.2655367278651, 0.273627368020151, 
    0.300575476345173), coxa3.posterior = c(0.32239302120667, 
    0.348797230641319, 0.322723594896146, 0.286924958124474, 
    0.310531068416563, 0.359451064344658), Coxa3.average = c(0.308059825499008, 
    0.320231948412369, 0.302780006360137, 0.276230843196563, 
    0.292079218218357, 0.330013270123579), femur1 = c(0.53344412311015, 
    0.594501676537536, 0.530217536295495, 0.514527850716328, 
    0.523402362157819, 0.724214250276451), femur2 = c(0.624844166341973, 
    0.62242266239383, 0.687751788591478, 0.595238122698798, 0.67101716194329, 
    0.657370505792677), femur3 = c(0.771499768530334, 0.709621950616875, 
    0.73045925924984, 0.709443126916381, 0.71782183270357, 0.731296991557455
    ), Forewing.length = c(3.90569163653097, 3.71735396284475, 
    3.70870245967632, 3.67271997731286, 3.89468979918273, 3.91102248411048
    ), Forewing.width = c(1.14083920932507, 1.24054979613491, 
    1.22159545808208, 1.1424536620426, 1.29973004580049, 1.10004419021568
    ), Forewingsurice.area = c(10.7250294361749, 10.7357182857541, 
    11.2447860996532, 10.3974705849124, 11.2478641830568, 9.71889046379367
    ), tarsi1_1 = c(0.14790195113684, 0.127147764272682, 0.137389192375109, 
    0.132364817915656, 0.131413146374404, 0.149623723140197), 
    tarsi1_2 = c(0.0851682561130301, 0.0816151169968028, 0.0777598691430841, 
    0.0762711871041436, 0.0819081932949372, 0.086321375636013
    ), tarsi1_3 = c(0.05899459957015, 0.0618556656924223, 0.0612409299273872, 
    0.0613397899673706, 0.0594059432453148, 0.0584329328546814
    ), tarsi1_4 = c(0.0340673036084858, 0.0300687276311245, 0.0273972594295365, 
    0.0298627938699947, 0.0288028831418247, 0.0332005316106093
    ), tarsi1_5 = c(0.0781055209485422, 0.0923539508709525, 0.0862207865660963, 
    0.0960452026260472, 0.0918091839108305, 0.0987162455869307
    ), tarsi1tot = c(0.404237631377048, 0.393041225034431, 0.390008037038313, 
    0.395883791483213, 0.393339350417356, 0.426294808828432), 
    tarsi2_1 = c(0.179891974784803, 0.185996557201992, 0.183319900195347, 
    0.194915264093515, 0.190819089619718, 0.217352803588656), 
    tarsi2_2 = c(0.0905691687216469, 0.121134019176011, 0.117244156225387, 
    0.108958845465276, 0.10531053520073, 0.129260729462848), 
    tarsi2_3 = c(0.0889073519821446, 0.0837628811084026, 0.0753424647406533, 
    0.0750605365433736, 0.0823582392230224, 0.0960601978522388
    ), tarsi2_4 = c(0.0319900282179677, 0.0356529186168164, 0.0342465741861955, 
    0.0294592417998321, 0.039153916085443, 0.032315182365712), 
    tarsi2_5 = c(0.157457414941948, 0.124570439606804, 0.144641410417212, 
    0.114205004217583, 0.134563461120325, 0.137228859386712), 
    tarsi2tot = c(0.548815938233055, 0.551116815710026, 0.554794505764795, 
    0.522598892523131, 0.552205241699284, 0.612217772213493), 
    tarsi3_1 = c(0.310344810480925, 0.284364252740063, 0.212328761485435, 
    0.256658594428061, 0.280828103319559, 0.285524552019457), 
    tarsi3_2 = c(0.145824678654506, 0.165807558229931, 0.130539881647459, 
    0.151331723647517, 0.158865888131613, 0.165117302168043), 
    tarsi3_3 = c(0.12172829459396, 0.104381440634743, 0.0789685681210926, 
    0.0956416505558846, 0.0967596828191374, 0.103585653153654
    ), tarsi3_4 = c(0.0415454916076207, 0.0365120268387758, 0.0350523743106695, 
    0.0431799855509762, 0.0409540966474686, 0.0349712270016878
    ), tarsi3_5 = c(0.172829247098504, 0.150773196132581, 0.154311026818233, 
    0.145278460351334, 0.133213330086744, 0.141212924791317), 
    tarsi3tot = c(0.792272522435516, 0.741838474576093, 0.61120061278579, 
    0.692090414533774, 0.710621101004522, 0.730411659134159), 
    tibia1 = c(0.672621484952058, 0.606529166301326, 0.617647027480212, 
    0.64326070605379, 0.701170139665048, 0.734838388979717), 
    tibia2 = c(0.734939761208523, 0.680841920542057, 0.645850109596671, 
    0.717110574280138, 0.780378064142149, 0.729083625085317), 
    tibia3 = c(1.07935188194521, 0.974656351266629, 1.02095076737815, 
    0.9196933462701, 1.07560766416314, 1.06241701109683), Trochanter1.anterior = c(0.142916494686509, 
    0.0987972496490506, 0.0894439939133073, 0.102905570062555, 
    0.0931593216950861, 0.0951748552474476), Trochanter1.posterior = c(0.133361030881401, 
    0.120704458621732, 0.0995165119881685, 0.112994354060364, 
    0.10531053520073, 0.118193883379276), Trochanter1.average = c(0.138138762783955, 
    0.109750854135391, 0.0944802527492875, 0.10794996206146, 
    0.0992349286729306, 0.106684369313362), Trochanter2.anterior = c(0.158288326427611, 
    0.120704458621732, 0.109991937780383, 0.0948345464155595, 
    0.107110718913071, 0.141212924791317), Trochanter2.posterior = c(0.130868296424412, 
    0.127147764272682, 0.155519737883267, 0.1343825722132, 0.151215127156145, 
    0.154050456084472), Trochanter2.average = c(0.144578311426012, 
    0.123926111447207, 0.132755838033276, 0.114608559516156, 
    0.129162923034608, 0.147631690437894), Trochanter3.anterior = c(0.181969248928957, 
    0.150343635578303, 0.165189354284288, 0.131557713775331, 
    0.148064812410224, 0.146082338998146), Trochanter3.posterior = c(0.132114657421083, 
    0.171391742772324, 0.166398053665197, 0.133575468072875, 
    0.162466255556294, 0.167773349902735), Trochanter3.average = c(0.157041952967292, 
    0.16086768939009, 0.165793703974743, 0.132566591125879, 0.155265534208282, 
    0.156927844671778), Overall.body.Size.Estimator = c(1, 1, 
    1, 1, 1, 1)), row.names = c(NA, 6L), class = "data.frame")
r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source