Tools functions

graph.var

This function allows to plot the graph of variables after a principal components method, keeping only the variables the user is interested in.

An example with the data set "decathlon": library(FactoMineR)
data(decathlon)
res.pca = PCA(decathlon, quanti.sup=11:12, quali.sup=13, graph=FALSE)
graph.var (res.pca, draw=c("var","Points"), label=c("Long.jump","Points"), lim.cos2.var=0.5, new.plot=TRUE)
#res.pca: the result of the PCA
#draw: the variables to plot ("var" for all active variables, "quanti.sup" for all supplementary continuous variables, or names)
#label: the labels to plot (again names, "var" or "quanti.sup")
#lim.cos2.var: the square cosinus limit under which the variable is not plotted anymore
#new.plot: creates or not a new graphical device

Scatter plot of the variables with selection of variables Click to view

write.infile

This function is useful to print a result or object into a file.

Examples: library(FactoMineR)
data(decathlon)
res.pca = PCA(decathlon, quanti.sup=11:12, quali.sup=13, graph=FALSE)
write.infile(decathlon, file="decathlon.xls", sep="\t")
write.infile(res.pca$eig, file="eigenvalues.txt", sep="\t")
#decathlon/res.pca: the object to print in a file
#file: a connection or a character string naming the file to print into
#sep: the character string to insert between the objects to print

coord.ellipse

This function draws confidence ellipses around the categories of a supplementary categorical variable.
It uses a data set with the categorical variable and the coordinates of the individuals on the principal components.

library(FactoMineR)
data(decathlon)
res.pca = PCA(decathlon, quanti.sup=11:12, quali.sup=13, graph=FALSE)
concat.data = cbind.data.frame(decathlon[,13],res.pca$ind$coord)
ellipses.coord = coord.ellipse(concat.data,bary=TRUE)
plot.PCA(res.pca, habillage=13, ellipse=ellipses.coord)
#concat.data: a data frame with the categorical variables and the coordinates of the individuals
#bary: calculates the coordinates of the ellipses around the barycentre of individuals if TRUE
#ellipse: draws ellipses

Confidence ellipses around a supplementary categorical variable Click to view

textual

This function calculates the number of occurence of each word and returns the contingency table.

library(FactoMineR)
data(poison.text)
res.text = textual(poison.text, num.text=3, contingence.by=c(1,2))
#poison.text: a data frame with one textual variable
#num.text: the indice of the textual variable
#contingence.by: a list with the indices of the variables and couples of variables for which a contingency table is calculated

Contingency table Click to view

The contingency table is built with in rows the categories of the selected categorical variables, in columns the words and in each cell the number of occurence of the considered word for the considered category.

Number of occurence of each word Click to view

A data frame is also provided with for each word the number of occurence and the number of lists in which it is present .

reconst

This function reconstructs a data set from the result of a PCA or a MFA.

library(FactoMineR)
data(decathlon)
res.pca = PCA(decathlon, quanti.sup = 11:12, quali.sup=13, graph=FALSE)
rec = reconst(res.pca,ncp=5)
#res.pca: the result of a PCA or MFA
#ncp: the number of dimensions to use to reconstitute data

coeffRV

This function calculates the RV coefficient between two matrices and tests its significance.

library(FactoMineR)
data(wine)
X = wine[,3:7]
Y = wine[,11:20]
coeffRV(X,Y)