Learn R Programming

aridagri (version 2.0.3)

pca_analysis: Principal Component Analysis

Description

Performs PCA with visualization suitable for agricultural research data. Includes scree plot, biplot, and variable contributions.

Usage

pca_analysis(data, scale = TRUE, ncp = 5, plot = TRUE, verbose = TRUE)

Value

PCA results with eigenvalues, loadings, and scores

Arguments

data

Data frame with numeric variables

scale

Logical, whether to scale variables (default TRUE)

ncp

Number of components to retain (default 5)

plot

Logical, whether to generate plots

verbose

Logical. If TRUE (default), prints formatted output to console.

Author

Lalit Kumar Rolaniya, ICAR-IIPR, Bikaner

Examples

Run this code
data <- data.frame(
  yield = rnorm(30, 1200, 200),
  wue = rnorm(30, 4.5, 0.5),
  protein = rnorm(30, 22, 2),
  biomass = rnorm(30, 3500, 500)
)
pca_analysis(data)

Run the code above in your browser using DataLab