[R] Help with plot of PCA analysis (new user to R)
darkpollo
darkpollo at gmail.com
Thu Mar 8 09:40:50 CET 2012
I was thinking to create the plot manually?
What do you think?
Thanks
On Mar 7, 5:37 pm, darkpollo <darkpo... at gmail.com> wrote:
> Hi,
>
> I am new to R and i am not sure if i am doing something wrong.
>
> I have a table with 4500x24 (rowsxcols) elements. The rows are data
> related to each one of the individuals (A,B,C...) located on the
> columns.
> Example:
> A B C D E F
> 1 5.651296 5.480589 4.253070 3.515593 6.045253 5.916222
> 4.181060
> 2 9.402882 10.007563 9.838700 9.541653 9.968853 10.058527
> 9.988849
> 3 9.619392 10.358489 9.253168 10.295971 9.478020 9.574001
> 9.700798
> 4 12.727904 12.624954 12.945821 12.948913 12.703855 12.817992
> 12.909623
> 5 9.713688 10.057340 9.380006 9.722916 9.590145 9.237900
> 9.224427
> 6 11.329047 11.403621 12.555482 11.830408 11.479372 13.035209
> 14.550555
>
> What i want to do is to make a PCA and plot the 3 principal components
> into a 3D graphic for each one of the individuals.
>
> This is what i am doing:
> data <- read.table("data.txt", header=TRUE)
> pca <- prcomp(data)
> summary(pca)
> this gives me 24 columns wiht PC1 to PC24
>
> Now i want to plot only the PC1, PC2 and PC3
>
> rp.plot3d(pca[,1],pca[,2],pca[,3])
>
> this give an error "incorrect number of dimensions"
>
> If i make this instead:
> pca.sam <- pca$x
> rp.plot3d(pca.sam[,1],pca.sam[,2],pca.sam[,3])
>
> It works, but it shows 4500 points and i only want the 24 points
> related to my columns.
>
> Any idea how to do this?
>
> Thanks
>
> Thanks
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list