The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
explor
is an R package to allow interactive exploration of multivariate analysis results.
For now on, the following analyses are supported :
Analysis | Function | Package | Notes |
---|---|---|---|
Principal component analysis | PCA | FactoMineR | - |
Correspondance analysis | CA | FactoMineR | - |
Multiple correspondence analysis | MCA | FactoMineR | - |
Principal component analysis | dudi.pca | ade4 | Qualitative supplementary variables are ignored |
Correspondance analysis | dudi.coa | ade4 | - |
Multiple correspondence analysis | dudi.acm | ade4 | Quantitative supplementary variables are ignored |
Specific Multiple Correspondance Analysis | speMCA | GDAtools | - |
Multiple Correspondance Analysis | mca | MASS | Quantitative supplementary variables are not supported |
Principal Component Analysis | princomp | stats | Supplementary variables are ignored |
Principal Component Analysis | prcomp | stats | Supplementary variables are ignored |
Correspondance Analysis | textmodel_ca | quanteda.textmodels | Only coordinates are available |
The philosophy behind explor
is to only be an exploration interface which doesn’t really do anything by itself : analysis and computations are made in your R script, and explor
only helps you visualizing the results. As such it can not disrupt code execution and reproducibility.
For each type of analysis, explor
launches a shiny
interactive Web interface which is displayed inside RStudio or in your system Web browser. This interface provides a series of tabs with interactive data and graphics.
These data and graphics are displayed with several “interactive” features. Numerical results are shown as dynamic tables which are sortable and searchable thanks to the DT
package. Most graphics are generated with the scatterD3
package which provides the following features :
Usage is very simple : you just apply the explor()
function to the result object of one of the supported analysis functions.
prcomp
, princomp
and MASS::mca
To visualize and explore these functions results, just pass the result object to explor()
.
Here is an example for a sample PCA with princomp
:
data(USArrests)
princomp(USArrests, cor = TRUE)
pca <-explor(pca)
explor
supports the visualization of supplementary individuals whose scores have been computed with predict
. You just have to add them as a supi
element to your result object.
Here is an example with prcomp
:
prcomp(USArrests[6:50,], scale. = TRUE)
pca <-$supi <- predict(pca, USArrests[1:5,])
pcaexplor(pca)
For MASS::mca
, explor()
also supports qualitative supplementary variables. You must include their predicted coordinates to a supv
element. It’s also best to manually add row names to the supi
data, if any :
library(MASS)
MASS::mca(farms[4:20, 2:4], nf = 11)
mca <- farms[1:3, 2:4]
supi_df <- predict(mca, supi_df, type="row")
supi <-rownames(supi) <- rownames(supi_df)
$supi <- supi
mca$supv <- predict(mca, farms[4:20, 1, drop=FALSE], type="factor")
mcaexplor(mca)
Note that the results of these three functions are quite limited : they provide variables and individuals coordinates, but no contributions or squared cosinus.
FactoMineR
functionsSupported FactoMineR
functions should work “out of the box”. Just pass the result object to explor()
.
Example with a principal correspondence analysis from FactoMineR::PCA
:
library(FactoMineR)
data(decathlon)
PCA(decathlon[,1:12], quanti.sup = 11:12)
pca <-explor(pca)
Example with a simple correspondence analysis from FactoMiner::CA
:
data(children)
CA(children, row.sup = 15:18, col.sup = 6:8)
res.ca <-explor(res.ca)
Example with a multiple correspondence analysis from FactoMineR::MCA
:
library(FactoMineR)
data(hobbies)
MCA(hobbies[1:1000, c(1:8,21:23)], quali.sup = 9:10,
mca <-quanti.sup = 11, ind.sup = 1:100)
explor(mca)
ade4
functionsade4
functions should also work by directly passing the object result to explor()
.
For example, to visualize a simple PCA results :
library(ade4)
data(deug)
dudi.pca(deug$tab, scale = TRUE, scannf = FALSE, nf = 5)
pca <-explor(pca)
There’s a bit more work to be done if you want to display supplementary elements, as ade4
don’t include them directly in the results analysis.
For a principal component analysis, you have to compute supplementary individuals (resp. variables) results with suprow
(resp. supcol
) and add them manually as a supi
(resp. supv
) element of your result object.
Here is an example of how to do this :
data(deug)
deug$tab
d <- d[-(1:10), 8:9]
sup_var <- d[1:10, -(8:9)]
sup_ind <- dudi.pca(d[-(1:10), -(8:9)], scale = TRUE, scannf = FALSE, nf = 5)
pca <-## Supplementary individuals
$supi <- suprow(pca, sup_ind)
pca## Supplementary variables
$supv <- supcol(pca, dudi.pca(sup_var, scale = TRUE, scannf = FALSE)$tab)
pcaexplor(pca)
You have to do the same thing for supplementary elements in a multiple correspondence analysis :
data(banque)
banque[-(1:100),-(19:21)]
d <- banque[1:100, -(19:21)]
ind_sup <- banque[-(1:100),19:21]
var_sup <- dudi.acm(d, scannf = FALSE, nf = 5)
acm <-## Supplementary variables
$supv <- supcol(acm, dudi.acm(var_sup, scannf = FALSE, nf = 5)$tab)
acm## Supplementary individuals
$supi <- suprow(acm, ind_sup)
acmexplor(acm)
For simple correspondence analysis, you can add supplementary rows or columns by adding their coordinates to supr
and supc
elements of your result object :
data(bordeaux)
bordeaux
tab <- tab[5,-4]
row_sup <- tab[-5,4]
col_sup <- dudi.coa(tab[-5,-4], nf = 5, scannf = FALSE)
coa <-$supr <- suprow(coa, row_sup)
coa$supc <- supcol(coa, col_sup)
coaexplor(coa)
GDAtools
functionsGDAtools
functions should also work by directly passing the object result to explor()
.
For example, to visualize a speMCA
results :
library(GDAtools)
data(Music)
speMCA(Music[,1:5], excl = c(3, 6, 9, 12, 15))
mca <-explor(mca)
To display supplementary individuals, you have to compute their data with the indsup
function, and add them manually as a supi
element of your result object :
speMCA(Music[3:nrow(Music), 1:5], excl = c(3, 6, 9, 12, 15))
mca <-$supi <- indsup(mca, Music[1:2, 1:5])
mcaexplor(mca)
To display supplementary variables, you have to compute their data with the speMCA_varsup
function and add them manually as a supv
element of your result object :
speMCA(Music[3:nrow(Music), 1:4], excl = c(3, 6, 9, 12))
mca <-$supi <- indsup(mca, Music[1:2, 1:4])
mca$supv <- speMCA_varsup(mca, Music[3:nrow(Music), 5:6])
mcaexplor(mca)
explor
provides two different ways to export the displayed plots.
To save the displayed plot as an SVG file, click on the Export to SVG button in the bottom of the left sidebar, or choose Export to SVG in the gear menu.
SVG is a vector graphics format, editable with softwares like Inkscape.
This SVG export may cause issues when used inside RStudio. As a workaround, you can open explor
in a browser (with Open in Browser icon) before exporting.
Another way is to get the R code which allows to generate the current plot. This code can then be used in a script or a Rmarkdown document.
To do this, click on the Get R code button on the bottom of the left sidebar. A modal dialog should show up with the R code that you can then copy/paste.
Please note that this R code keeps track of the current plot zooming, but not of any custom label positioning. If you want to keep those, you have to first save them in a CSV file with Export labels positions gear menu entry. Then, in your R script, read this file in an object with read.csv
and pass this object to the export_labels_positions
argument in the generated code :
read.csv("position_labels.csv")
labels <- explor::prepare_results(mca)
res <-::MCA_var_plot(res, xax = 1, yax = 2,
explorvar_sup = TRUE, , var_lab_min_contrib = 0,
col_var = "Variable", symbol_var = "Type",
size_var = NULL, size_range = c(10, 300),
labels_size = 10, point_size = 56,
transitions = TRUE, labels_positions = labels)
explor
is quite a young package, so there certainly are bugs or problems. Thanks for reporting them by mail or by opening an issue on GitHub
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.