1. Importer les données

univ <- read.table("https://r-stat-sc-donnees.github.io/universite.csv", sep = ";", 
                   header = T, row.names = 1)
summary(univ)
   Licence.F       Licence.H        Master.F        Master.H       Doctorat.F    
 Min.   : 1779   Min.   :  726   Min.   : 1963   Min.   :  811   Min.   :   0.0  
 1st Qu.:19570   1st Qu.:15566   1st Qu.: 5910   1st Qu.: 3948   1st Qu.: 600.8  
 Median :31353   Median :19571   Median :15132   Median : 7155   Median :3006.0  
 Mean   :38901   Mean   :25490   Mean   :18238   Mean   :14341   Mean   :3041.8  
 3rd Qu.:59225   3rd Qu.:37277   3rd Qu.:26518   3rd Qu.:21382   3rd Qu.:4500.0  
 Max.   :94346   Max.   :54861   Max.   :43016   Max.   :48293   Max.   :7787.0  
   Doctorat.H         Total.F          Total.H          Licence           Master     
 Min.   :    0.0   Min.   :  4148   Min.   :  1552   Min.   :  2505   Min.   : 3167  
 1st Qu.:  472.8   1st Qu.: 27330   1st Qu.: 22833   1st Qu.: 33052   1st Qu.: 9565  
 Median : 2476.5   Median : 56940   Median : 27399   Median : 71043   Median :21536  
 Mean   : 3424.0   Mean   : 60181   Mean   : 43255   Mean   : 64391   Mean   :32579  
 3rd Qu.: 5009.5   3rd Qu.: 76044   3rd Qu.: 65817   3rd Qu.: 82375   3rd Qu.:61696  
 Max.   :11491.0   Max.   :145149   Max.   :114645   Max.   :135396   Max.   :65371  
    Doctorat         Total       
 Min.   :    0   Min.   :  5700  
 1st Qu.: 1074   1st Qu.: 45957  
 Median : 5734   Median :100416  
 Mean   : 6466   Mean   :103436  
 3rd Qu.:10248   3rd Qu.:153135  
 Max.   :15898   Max.   :213618  
univ[1:4,1:3]
                                     Licence.F Licence.H Master.F
Droit, sciences politiques               69373     37317    42371
Sciences economiques, gestion            38387     37157    29466
Administration economique et sociale     18574     12388     4183
Lettres, sciences du langage, arts       48691     17850    17672

2 et 3. Paramétrer et réaliser l’AFC

library(FactoMineR)
res.ca <- CA(univ, col.sup = 7:12)

summary(res.ca, nb.dec = 2, ncp = 2, nbelements = 3)

Call:
CA(X = univ, col.sup = 7:12) 

The chi square of independence between the two variables is equal to 170789.2 (p-value =  0 ).

Eigenvalues
                      Dim.1  Dim.2  Dim.3  Dim.4  Dim.5
Variance               0.12   0.03   0.02   0.00   0.00
% of var.             70.72  15.51  10.90   2.63   0.25
Cumulative % of var.  70.72  86.23  97.13  99.75 100.00

Rows (the 3 first)
                                                              Iner*1000   Dim.1   ctr  cos2  
Droit, sciences politiques                                  |      5.72 | -0.10  1.45  0.30 |
Sciences economiques, gestion                               |      9.78 |  0.18  3.85  0.46 |
Administration economique et sociale                        |      6.43 | -0.19  1.10  0.20 |
                                                            Dim.2   ctr  cos2  
Droit, sciences politiques                                   0.07  2.86  0.13 |
Sciences economiques, gestion                               -0.02  0.12  0.00 |
Administration economique et sociale                        -0.37 20.03  0.80 |

Columns (the 3 first)
                                                              Iner*1000   Dim.1   ctr  cos2  
Licence.F                                                   |     48.35 | -0.35 39.72  0.96 |
Licence.H                                                   |     24.31 |  0.23 11.51  0.55 |
Master.F                                                    |     16.11 | -0.11  1.99  0.14 |
                                                            Dim.2   ctr  cos2  
Licence.F                                                   -0.04  2.27  0.01 |
Licence.H                                                   -0.20 37.49  0.39 |
Master.F                                                     0.17 20.90  0.33 |

Supplementary columns (the 3 first)
                                                              Dim.1  cos2   Dim.2  cos2  
Total.F                                                     | -0.26  0.96 |  0.05  0.03 |
Total.H                                                     |  0.37  0.96 | -0.07  0.03 |
Licence                                                     | -0.12  0.55 | -0.10  0.40 |

4. Choisir le nombre d’axes

barplot(res.ca$eig[,2], names = paste("Dim", 1:nrow(res.ca$eig)))

5. Visualiser les résultats

plot(res.ca, invisible = c("col","col.sup"))

# axes 3 et 4
plot(res.ca, axes = 3:4)

Factoshiny

library(Factoshiny)
res.shiny <- CAshiny(univ)
LS0tDQp0aXRsZTogIkFuYWx5c2UgRmFjdG9yaWVsbGUgZGVzIENvcnJlc3BvbmRhbmNlcyINCmF1dGhvcjogIkh1c3Nvb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