Learn R Programming

statisR (version 1.0.1)

select.super.variables: Select and prepare a subset of variables from a supervision matrix

Description

This function selects a predefined subset of variables (ETCal) from a supervision matrix (superv), checks dimension consistency, verifies missing variables, and constructs a clean data frame containing the first two coordinates typically used for PCA or STATIS correlation plots.

Usage

select.super.variables(superv, ET, ETCal)

Value

A data frame with two columns:

  • x: first coordinate (e.g., PC1)

  • y: second coordinate (e.g., PC2)

Row names correspond to the selected variables defined in ETCal.

Arguments

superv

A numeric matrix or data frame where each row corresponds to a variable and columns represent coordinates (res$supervariables).

ET

A character vector containing the full list of expected variable names (res$vars.names).

ETCal

A character vector containing the subset of variables to be selected.

Details

The function performs the following steps:

  1. Checks that the number of rows in superv matches the length of ET.

  2. Assigns the row names of superv using ET.

  3. Identifies whether any variables in ETCal are missing in superv; missing variables trigger a warning.

  4. Creates an ordered list of valid variables (ETCal_ok) based on their presence in superv.

  5. Extracts the corresponding rows from superv and constructs a data frame with columns x and y.

Examples

Run this code
data(Tuis5_95, Tuis5_96, Tuis5_97, Tuis5_98)
labels <- c("95","96","97","98")

res <- statis.dual(list(Tuis5_95, Tuis5_96, Tuis5_97, Tuis5_98), labels.tables = labels)

ETCal <- c("Ph","Temp","DBO","ST","PO4","NO3","POD","Cal")

df_selected <- select.super.variables(res$supervariables, res$vars.names, ETCal)

Run the code above in your browser using DataLab