<html><body><div style="font-family: trebuchet ms,sans-serif; font-size: 12pt; color: #000000"><div>Hi,</div><div><br></div><div>can you make your example reproducible (simulate some data)?</div><div><br></div><div>As for the n.pca.max argument. PCA is a dimension reduction technique. Which means it tries to present data of N variables (columns) as as few principal components as possible. If you think of a 3D cloud shaped like a sphere (3 variables describe this, call them x, y and z), PCA will try to show you the data in 2D (two principal components, call them PC1 and PC2). What you expect to see is a circle which explains most of the variation, since circle is quite good approximation of a sphere. If you add data from PC3, you get a sphere again (and all variation explained). </div><div><br></div><div>Retaining all components is not practical so the function will retain only `n.pca.max` components.</div><div><br></div><div>Cheers,</div><div>Roman</div><div><br></div><div><span name="x"></span>----<br>In god we trust, all others bring data.<span name="x"></span><br></div><div><br></div><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Kirsty Medcalf" <kirsty.m.medcalf@gmail.com><br><b>To: </b>adegenet-forum@lists.r-forge.r-project.org<br><b>Sent: </b>Monday, September 28, 2015 4:44:06 AM<br><b>Subject: </b>[adegenet-forum] Cross validation using xvalDapc<br><div><br></div><div dir="ltr">Hi <div><br></div><div>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. If this is possible, I was wondering if anyone had a solution to this error message (below).  I have looked online and through available tutorials and still cannot </div><div>solve this issue.</div><div><br></div><div><div>Error in sort.list(y) : 'x' must be atomic for 'sort.list'<br></div><div>Have you called 'sort' on a list?</div></div><div><br></div><div> Also, I have confusion regarding the argument n.pca.max.  My data frame has two grouping dependent factors, 12 predictor values and 80 observations.  Would n.pca.max=80 be correct? <br></div><div><br></div><div>If it is possible to help me, then thank you</div><div><br></div><div>Best wishes,</div><div>Kirsty</div><div><br></div><div>CODE</div><div><br></div><div>#Permute the data<br></div><div>set.seed(999) </div><div><br></div><div>#DAPC analysis</div><div><br></div><div><div>windows(width=10, height=7)</div><div>x<-LDA.scores[,2:13]</div><div>grp1<-find.clusters(x, max.n.clust=12)</div><div>dapc1<-dapc(x, grp1$grp)</div><div>dapc1</div><div><br></div><div>windows(width=10, height=7)<br></div></div><div><div><div><div><div>x1 <- LDA.scores</div><div>mat <- as.matrix(x1, method="mean")</div><div>grp2 <- x1</div><div>xval <- xvalDapc(mat, grp2, n.pca.max = 80, training.set = 0.7,</div><div>                 result = "groupMean", center = TRUE, scale = FALSE,</div><div>                 n.pca = NULL, n.rep = 30, xval.plot = TRUE)</div></div><div><br></div><div><br></div><div><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><br></div><div><br></div><div>Kirsty Medcalf</div><div> </div><div><a href="mailto:kirsty.m.medcalf@gmail.com" target="_blank" data-mce-href="mailto:kirsty.m.medcalf@gmail.com">kirsty.m.medcalf@gmail.com</a></div><div> </div><div><a href="tel:%2B447963374030" target="_blank" data-mce-href="tel:%2B447963374030">+447963374030</a></div><div> </div><div>skype contact: kirsty.medcalf</div></div></div></div></div><br>_______________________________________________<br>adegenet-forum mailing list<br>adegenet-forum@lists.r-forge.r-project.org<br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</div><div><br></div></div></body></html>