| Type: | Package |
| Title: | Correspondence Analysis Biplots and Diagnostic Reports |
| Version: | 0.1.0 |
| Description: | A convenience wrapper around 'FactoMineR' and 'factoextra' for running Correspondence Analysis (CA) on a numeric data table (e.g. a genotype-by-trait or contingency-style matrix) and producing a full set of publication-ready diagnostic plots: scree plot, symmetric biplot, row-only and column-only plots, row/column contribution plots, and row/column cos2 (quality-of-representation) plots. A single top-level function runs the whole pipeline, prints formatted result tables, and optionally saves every plot as a high-resolution image, mirroring a typical CA reporting workflow used in agronomy and plant-breeding studies. An example genotype-by-trait data set is included. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 3.5.0) |
| Imports: | FactoMineR, factoextra, ggplot2, gridExtra, utils |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.1 |
| NeedsCompilation: | no |
| Packaged: | 2026-09-15 07:00:02 UTC; iasri |
| Author: | Prakash Kumar [aut, cre], Himadri Sekhar Roy [aut], Ranjit Kumar Paul [aut], Md. Yeasin [aut], Sunil Kumar Yadav [aut], Amrit Kumar Paul [aut] |
| Maintainer: | Prakash Kumar <prakash289111@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-24 15:00:08 UTC |
CAbiplot: Correspondence Analysis Biplots and Diagnostic Reports
Description
Provides a convenience wrapper around FactoMineR and factoextra for running Correspondence Analysis (CA) on a numeric data table and producing a full set of publication-ready diagnostic plots.
Main functions
read_ca_dataRead a delimited text file into a numeric
data.frameready for CA.get_genotype_traitsLoad the bundled example genotype-by-trait data set.
run_caRun
CAon a data table or file path.ca_scree_plot,ca_biplot,ca_row_plot,ca_col_plot,ca_contrib_plot,ca_cos2_plotBuild the individual diagnostic plots.
ca_reportRun the whole pipeline end to end, optionally saving every plot and printing formatted result tables.
Symmetric CA biplot (rows and columns)
Description
Symmetric CA biplot (rows and columns)
Usage
ca_biplot(res.ca, axes = c(1, 2), col.row = "#1F4E79",
col.col = "#B22222", ...)
Arguments
res.ca |
|
axes |
Length-2 integer vector of the dimensions to plot. Defaults
to |
col.row |
Color for row points/labels. Defaults to |
col.col |
Color for column points/labels. Defaults to
|
... |
Additional arguments passed to
|
Value
A ggplot object.
CA column-only plot
Description
CA column-only plot
Usage
ca_col_plot(res.ca, axes = c(1, 2), col.col = "#B22222", ...)
Arguments
res.ca |
|
axes |
Length-2 integer vector of the dimensions to plot. Defaults
to |
col.col |
Color for column points/labels. Defaults to
|
... |
Additional arguments passed to
|
Value
A ggplot object.
Row or column contribution plot
Description
Row or column contribution plot
Usage
ca_contrib_plot(res.ca, choice = c("row", "col"), axes = 1, top = NULL, ...)
Arguments
res.ca |
|
choice |
Either |
axes |
Integer vector of dimension(s) to sum contributions over.
Defaults to |
top |
Number of rows/columns to display. Defaults to all of them. |
... |
Additional arguments passed to
|
Value
A ggplot object.
Row or column cos2 (quality of representation) plot
Description
Row or column cos2 (quality of representation) plot
Usage
ca_cos2_plot(res.ca, choice = c("row", "col"), axes = 1:2, top = NULL, ...)
Arguments
res.ca |
|
choice |
Either |
axes |
Integer vector of dimension(s) to sum cos2 over. Defaults to
|
top |
Number of rows/columns to display. Defaults to all of them. |
... |
Additional arguments passed to
|
Value
A ggplot object.
Run a full Correspondence Analysis report
Description
End-to-end pipeline that runs Correspondence Analysis on data and
produces the full battery of diagnostic plots used in the package
vignette: a scree plot, a symmetric biplot, row-only and column-only
plots, row and column contribution plots (dimensions 1 and 2), row and
column cos2 plots, and a combined summary figure. Optionally saves every
plot as a high-resolution JPEG and prints formatted result tables to the
console, mirroring a typical CA reporting workflow.
Usage
ca_report(data, output_dir = ".", prefix = "CA", save_plots = TRUE,
dpi = 600, verbose = TRUE)
Arguments
data |
A numeric matrix, numeric |
output_dir |
Directory where plots are saved when
|
prefix |
File name prefix used for saved plots. Defaults to
|
save_plots |
Logical; save each plot as a JPEG in
|
dpi |
Resolution (dots per inch) used when saving plots. Defaults
to |
verbose |
Logical; print formatted result tables (eigenvalues,
coordinates, contributions, cos2) to the console? Defaults to
|
Value
Invisibly, a list with elements:
- res.ca
The fitted
"CA"object.- eig
Eigenvalue/inertia table from
get_eigenvalue.- plots
A named list of the individual
ggplotobjects (scree,biplot,row,col,contrib_row_dim1,contrib_row_dim2,contrib_col_dim1,contrib_col_dim2,cos2_row,cos2_col) pluscombined, agridExtraarrangement of the scree plot, biplot, and the two dimension-1 contribution plots.
Examples
geno <- get_genotype_traits()
report <- ca_report(geno, save_plots = FALSE, verbose = FALSE)
report$plots$biplot
CA row-only plot
Description
CA row-only plot
Usage
ca_row_plot(res.ca, axes = c(1, 2), col.row = "#1F4E79", ...)
Arguments
res.ca |
|
axes |
Length-2 integer vector of the dimensions to plot. Defaults
to |
col.row |
Color for row points/labels. Defaults to |
... |
Additional arguments passed to
|
Value
A ggplot object.
Scree plot of CA eigenvalues
Description
Scree plot of CA eigenvalues
Usage
ca_scree_plot(res.ca, ...)
Arguments
res.ca |
|
... |
Additional arguments passed to
|
Value
A ggplot object.
Load the bundled example genotype-by-trait data set
Description
Loads the example data set shipped with the package: a table of plant genotypes (rows) evaluated across six morphological/agronomic traits (columns). This is the same data used in the package vignette and examples.
Usage
get_genotype_traits()
Value
A numeric data.frame with genotypes as row names and traits as
columns.
Examples
geno <- get_genotype_traits()
head(geno)
Read a CA-ready numeric data table
Description
Reads a delimited text file into a numeric data.frame suitable for
CA. The first column is used as row names, and
every remaining column is coerced to numeric.
Usage
read_ca_data(file, sep = ",", header = TRUE, row.names = 1,
check.names = FALSE)
Arguments
file |
Path to a delimited text file (e.g. CSV). |
sep |
Field separator passed to |
header |
Logical; does the file have a header row? Defaults to
|
row.names |
Column to use as row names, passed to
|
check.names |
Logical; passed to |
Value
A numeric data.frame with row names taken from the input file.
Examples
file <- system.file("extdata", "genotype_traits.csv", package = "CAbiplot")
data <- read_ca_data(file)
head(data)
Run Correspondence Analysis on a numeric data table
Description
Thin, validating wrapper around CA. Accepts
either a numeric matrix/data.frame already in memory, or a path to a
delimited text file, which is read with read_ca_data.
Usage
run_ca(data, ...)
Arguments
data |
A numeric matrix, numeric |
... |
Additional arguments passed on to |
Value
An object of class "CA" as returned by
CA, computed with graph = FALSE.
Examples
geno <- get_genotype_traits()
res.ca <- run_ca(geno)
summary(res.ca)