<div dir="ltr"><div>Mauro, boa tarde!</div><div><br></div><div>Trabalhei um pouco em cima do seu código e cheguei a plotar as elipses, mas precisaria revisar o conteúdo de multivariada pra saber se o procedimento está correto. </div>
<div><br></div><div>De qualquer modo, posto o código para que você veja se é possível aproveitar algo.</div><div><br></div><div><font face="courier new, monospace">### <code r></font></div><div><font face="courier new, monospace">dURL <- ('<a href="https://www.dropbox.com/s/405ggda0h6scnie/marajoara320amostras.txt">https://www.dropbox.com/s/405ggda0h6scnie/marajoara320amostras.txt</a>')</font></div>
<div><font face="courier new, monospace">dURL2 <- ('<a href="https://dl.dropboxusercontent.com/s/405ggda0h6scnie/marajoara320amostras.txt?token_hash=AAFD9qRCKF1VECx1_j7-gf0ab93bFdJ2CojO4J_WYIh83w">https://dl.dropboxusercontent.com/s/405ggda0h6scnie/marajoara320amostras.txt?token_hash=AAFD9qRCKF1VECx1_j7-gf0ab93bFdJ2CojO4J_WYIh83w</a>')</font></div>
<div><font face="courier new, monospace">dName <- basename(dURL); dName</font></div><div><font face="courier new, monospace">download.file(dURL2, dName, mode='wb')</font></div><div><font face="courier new, monospace">file.show(dName)</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">maraOri <- read.table('marajoara320amostras.txt', head=FALSE); head(maraOri)</font></div><div><font face="courier new, monospace">maraNorm <- data.frame(scale(maraOri)); head(maraNorm)</font></div>
<div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace">### Cluster</font></div><div><font face="courier new, monospace">maraNorm.h <- hclust(dist(maraNorm)^2, method="ward")</font></div>
<div><font face="courier new, monospace">maraGroups <- cutree(maraNorm.h, 3); maraGroups</font></div><div><font face="courier new, monospace">maraInitial <- aggregate(maraNorm, by=list(maraGroups), mean)[,-1]; maraInitial</font></div>
<div><font face="courier new, monospace">maraNorm.km1 <- kmeans(maraNorm,maraInitial)</font></div><div><font face="courier new, monospace">plot(maraNorm.h, main="marajoara320amostras")</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">### PCA</font></div><div><font face="courier new, monospace">maraNorm.pca <- princomp(maraNorm)</font></div><div><font face="courier new, monospace">maraNorm.px <- predict(maraNorm.pca)</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">library(MASS)</font></div><div><font face="courier new, monospace">eqscplot(maraNorm.px[,1:2],type="n",xlab="componente 1",ylab="componente 2")</font></div>
<div><font face="courier new, monospace">text(maraNorm.px[,1:2],labels=as.character(maraNorm.km1$cluster),col=as.numeric(maraNorm.km1$cluster),cex=.5)</font></div><div><font face="courier new, monospace">title("marajoara320amostras")</font></div>
<div><font face="courier new, monospace">#identify(maraNorm.px[,1:2]) # identificar amostras no gráfico de PCA</font></div><div><font face="courier new, monospace">library(ellipse)</font></div><div><font face="courier new, monospace">tmp <- split(data.frame(maraNorm.px[,1:2]), maraGroups)</font></div>
<div><font face="courier new, monospace">lapply(tmp, cor)</font></div><div><font face="courier new, monospace">lapply(tmp, function(x) lines(ellipse(cor(x), level=0.95, centre=c(mean(x[,1]),mean(x[,2]))), lty=2))</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">### </code></font></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">Éder Comunello <<a href="mailto:comunello.eder@gmail.com" target="_blank">c</a><a href="mailto:omunello.eder@gmail.com" target="_blank">omunello.eder@gmail.com</a>> <br>
Dourados, MS - [22 16.5'S, 54 49'W]<br></div></div>
<br><br><div class="gmail_quote"><br></div></div></div>