<div dir="ltr"><span style="font-size:12.8px">Hi </span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I am attempting to cross validate my results from DAPC analysis with a 70 % training set using the function xvalDapc (code below).  My data frame is called LDA.scores. this is an updated version of a previous post after taking into account the recommendationsbut I am still outputting the same error message.  Do I have to change my data frame into a list? If so, what would be the correct format to transform the data frame into this format. If this is possible, I was wondering if anyone had a solution with how to solve this error message (below).  I have looked online and through available tutorials and still cannot <span style="font-size:12.8px">solve this issue.  Words cannot describe my gratitude if this is possible.</span></div><div style="font-size:12.8px"><br></div><div><div><pre style="font-size:13px;margin-top:0px;padding:5px;border:0px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> </span></code><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">#Permute the data</span></pre><pre style="font-size:13px;margin-top:0px;padding:5px;border:0px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><span style="white-space:inherit;margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">set.seed(999) </span></span></pre><pre style="font-size:13px;margin-top:0px;padding:5px;border:0px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><span style="white-space:inherit;margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">x</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><-</span><span style="white-space:inherit;margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">LDA.scores[,2:13]</span></pre><div><pre style="font-size:13px;margin-top:0px;padding:5px;border:0px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">   grp1</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><-</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">find.clusters</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">x</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> max.n.clust</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">=</span><span style="margin:0px;padding:0px;border:0px;color:rgb(128,0,0)">12</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">
   dapc1</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"><-</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">dapc</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">(</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">x</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">,</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)"> grp1</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">$</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">grp</span><span style="margin:0px;padding:0px;border:0px;color:rgb(0,0,0)">)</span></code></pre><pre style="margin-top:0px;padding:5px;border:0px;overflow:auto;width:auto;max-height:600px;word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px"><span style="margin:0px;padding:0px;border:0px"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal"><span style="font-size:12.8px">#DAPC analysis</span><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal"><br></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">windows(width=10, height=7)</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">x<-LDA.scores[,2:13]</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">grp1<-find.clusters(x, max.n.clust=12)</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">dapc1<-dapc(x, grp1$grp)</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">dapc1</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">#Loadings plot</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal"><br></div><div><div><font face="arial, sans-serif"><span style="font-size:12.8px;white-space:normal">contrib <- loadingplot(dapc1$var.contr, axis=2,</span></font></div><div><font face="arial, sans-serif"><span style="font-size:12.8px;white-space:normal">                       thres=.07, lab.jitter=1)</span></font></div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">#Cross Validation</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal">windows(width=10, height=7)<br></div></div><div style=""><div style=""><div style=""><div style=""><font face="arial, sans-serif"><span style="font-size:12.8px;white-space:normal">set.seed(1234)</span></font></div><div style=""><font face="arial, sans-serif"><span style="font-size:12.8px;white-space:normal">x1 <- LDA.scores</span></font></div><div style=""><font face="arial, sans-serif"><span style="font-size:12.8px;white-space:normal">str(x1)</span></font></div><div style=""><font face="arial, sans-serif"><span style="font-size:12.8px;white-space:normal">x1$Matriline<-as.factor(x1$Matriline)</span></font></div><div style=""><font face="arial, sans-serif"><span style="font-size:12.8px;white-space:normal">xval <- xvalDapc(x1, grp1, n.pca.max = 2, training.set = 0.7,</span></font></div><div style=""><font face="arial, sans-serif"><span style="font-size:12.8px;white-space:normal">                 result = "groupMean", center = TRUE, scale = FALSE,</span></font></div><div style=""><font face="arial, sans-serif"><span style="font-size:12.8px;white-space:normal">                 n.pca = NULL, n.rep = 30, xval.plot = TRUE)</span></font></div></div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;white-space:normal"><div>Error in sort.list(y) : 'x' must be atomic for 'sort.list'</div><div>Have you called 'sort' on a list?</div></div></div></span></code></pre><div style="font-size:12.8px"><span style="font-size:12.8px">During the DAPC analysis,  I chose to retain 2 PCs and 2 LD's, and there appears to be 3 clusters. Would n.pca.max=2 be correct? </span><br></div></div></div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">My reproducible data, the logical steps that I took to chose the number of PC's and LD's to retain,  and the number of chosen clusters is available on stack overflow</div><div style="font-size:12.8px"><br></div><div><a href="http://stackoverflow.com/questions/32704902/discriminant-analysis-of-principal-components-and-how-to-graphically-show-the-di" target="_blank">http://stackoverflow.com/questions/32704902/discriminant-analysis-of-principal-components-and-how-to-graphically-show-the-di</a><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">If it is possible to help me, then thank you</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Best wishes,</div><div style="font-size:12.8px">Kirsty</div><div style="font-size:12.8px"><br></div><div><div><div><br></div><div><br></div><div><br></div><div><br></div></div></div>
</div>