R-CMD-check codecov CodeFactor Dependencies

r-universe CRAN Version CRAN checks CRAN Downloads

Project Status: Active – The project has reached a stable, usable state and is being actively developed.



Simple Principal Components Analysis (PCA) and Correspondence Analysis (CA) based on the Singular Value Decomposition (SVD). This package provides S4 classes and methods to compute, extract, summarize and visualize results of multivariate data analysis. It also includes methods for partial bootstrap validation.

There are many very good packages for multivariate data analysis (such as FactoMineR, ade4, vegan or ca, all extended by FactoExtra). dimensio is designed to be as simple as possible, providing all the necessary tools to explore the results of the analysis.

To cite dimensio in publications use:

  Frerebeau N (2023). _dimensio: Multivariate Data Analysis_.
  Université Bordeaux Montaigne, Pessac, France.
  doi:10.5281/zenodo.4478530 <https://doi.org/10.5281/zenodo.4478530>,
  R package version 0.3.1, <https://packages.tesselle.org/dimensio/>.

Une entrée BibTeX pour les utilisateurs LaTeX est

    author = {Nicolas Frerebeau},
    title = {{dimensio: Multivariate Data Analysis}},
    year = {2023},
    organization = {Université Bordeaux Montaigne},
    address = {Pessac, France},
    note = {R package version 0.3.1},
    doi = {10.5281/zenodo.4478530},
    url = {https://packages.tesselle.org/dimensio/},

This package is a part of the tesselle project


You can install the released version of dimensio from CRAN with:


And the development version from GitHub with:

# install.packages("remotes")


## Load packages



## Load data

## Compute PCA
## (non numeric variables are automatically removed)
X <- pca(iris, center = TRUE, scale = TRUE)
#> 1 qualitative variable was removed: Species.


dimensio provides several methods to extract the results:


The package allows to quickly visualize the results:

dimensio uses ggplot2 for plotting informations. Visualization methods produce graphics with as few elements as possible: this makes it easy to customize diagrams (e.g. using extra layers, themes and scales). The plot_*() functions allow to highlight additional information by varying different graphical elements (color, transparency, shape and size of symbols…).

## Form biplot
biplot(X, type = "form", label = "variables") +
  ggrepel::geom_label_repel() + # Add repelling labels
  ggplot2::theme_bw() + # Change theme
  ggplot2::theme(legend.position = "none") +
  khroma::scale_colour_highcontrast() # Custom color scale

## Highlight species
plot_individuals(X, colour = "group", group = iris$Species) +
  ggplot2::stat_ellipse() + # Add ellipses
  ggplot2::theme_bw() + # Change theme
  khroma::scale_colour_highcontrast() # Custom color scale
#> Warning: The following aesthetics were dropped during statistical transformation: label
#> ℹ This can happen when ggplot fails to infer the correct grouping structure in
#>   the data.
#> ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
#>   variable into a factor?

## Highlight petal length
plot_individuals(X, colour = "group", size = "group", group = iris$Petal.Length) +
  ggplot2::theme_bw() + # Change theme
  ggplot2::scale_size_continuous(range = c(1, 3)) + # Custom size scale
  khroma::scale_color_iridescent() # Custom color scale

## Plot variables factor map
plot_variables(X) +
  ggrepel::geom_label_repel() + # Add repelling labels
  ggplot2::theme_bw() # Change theme

## Highlight contributions
plot_variables(X, colour = "contrib") +
  ggrepel::geom_label_repel() + # Add repelling labels
  ggplot2::theme_bw() + # Change theme
  khroma::scale_color_YlOrBr(range = c(0.5, 1)) # Custom color scale

## Scree plot
plot_variance(X, variance = TRUE, cumulative = TRUE) +
  ggplot2::geom_text(nudge_y = 3) + # Add labels
  ggplot2::theme_bw() # Change theme

## Plot variables contributions to the definition of the first component
plot_contributions(X, margin = 2, axes = 1) +
  ggplot2::geom_text(nudge_y = 2) + # Add labels
  ggplot2::theme_bw() + # Change theme
  ggplot2::theme( # Edit theme
    # Rotate x axis labels
    axis.text.x = ggplot2::element_text(angle = 45, hjust = 1, vjust = 1)


Please note that the dimensio project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.