Working with FactoMineR.PCA

12 views
Skip to first unread message

Mahmood Naderan

unread,
Feb 4, 2021, 4:28:00 PMFeb 4
to factomin...@googlegroups.com
Hi
With the following test file

,V1,V2,V3,V4
P1,73.6,0.7,74.6,3.1
P2,75.2,0.7,75.8,2.8
P3,6.5,0.0,7.3,2.5
P4,41.4,0.3,39.2,8.9
P4,5.4,0.1,18.2,1.1
P5,18.8,0.3,30.3,7.3

I tried to run a PCA analysis with factominer.


> library(FactoMineR)
> mydata <- read.csv('test.csv', header=T)
> head(mydata)
X V1 V2 V3 V4
1 P1 73.6 0.7 74.6 3.1
2 P2 75.2 0.7 75.8 2.8
3 P3 6.5 0.0 7.3 2.5
4 P4 41.4 0.3 39.2 8.9
5 P4 5.4 0.1 18.2 1.1
6 P5 18.8 0.3 30.3 7.3


When I run
res.pca = PCA(mydata[,2:5], scale.unit=TRUE, graph=T)
I see https://pasteboard.co/JMQJdrHf.png with Dim1 (74.1%) and Dim2(25%).


I have these questions:
1- How can I specify which principal components to show? Since
74.1+25<100 it seems that there is another PC. I would like to see
PC1-PC3 and PC2-PC3.

2- As you can see in the picture, in the indices (row numbers) are
shown in the chart. I would like to see P1~P5 on the chart. How can I
do that?



Regards,
Mahmood

Womble

unread,
Feb 5, 2021, 5:40:28 AMFeb 5
to FactoMineR users
When you say "see your third component" do you mean see the maps of the scores?  The actual figures are within the results from your PCA.  To see the map of component 1 v 3 for example, run

plot(res.pca,axes=c(1,3))

changing 1 and 3 for whatever components you want.  It is in the manual under plot.PCA


If you set-up your data with the labels as the names for each row, these will be used in the plot.

mydata <- read.csv('test.csv', header=T, row.names=1)

You will have to correct the typo in your name that has two P4s or R will complain that your row names are not unique.

Best wishes, Kris.

Mahmood Naderan

unread,
Feb 5, 2021, 7:17:44 AMFeb 5
to factomin...@googlegroups.com
Thanks for the reply. I understand that.

Regards,
Mahmood
> --
> Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "FactoMineR users".
> Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse factominer-use...@googlegroups.com.
> Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/factominer-users/7df1ce8a-737b-41e4-b0cc-eda9ad8c2959n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages