Learn R Programming

PhysioIndexR (version 0.1.0)

WASI: Weighted Average Stress Index (WASI)

Description

A composite measure that computes the weighted mean for each genotype across multiple stress indices, accounting for whether higher or lower values are better.

Usage

WASI(data, decimals = 5)

Value

A data frame with Gen and its computed WASI (sorted in descending order).

Arguments

data

A data frame containing genotype IDs (Gen) and stress index values (GMP, HM, MP, MRP, PYR, RSI, SSPI, STI, TOL, YI, YSI).

decimals

Integer; number of decimal places to use for Excel-style data. All indices are rounded to this precision before ranking and again for the index × rank products (default 5).

Details

The Weighted Average Stress Index for genotype i is $$WASI_i = \frac{\sum_{j=1}^{k} (X_{ij} \times R_{ij})}{\sum_{j=1}^{k} R_{ij}},$$ where \(X_{ij}\) is the value of genotype i for index j, and \(R_{ij}\) is its rank, determined by whether higher or lower values are favorable. Ranks use Excel-like behavior (ties.method = "min"). Indices are rounded to decimals places prior to ranking and multiplication to better match Excel-style calculations.

Examples

Run this code
df <- data.frame(
Gen = paste0("G", 1:5),
GMP  = c(1:5),
HM   = c(6:10),
MP   = c(11:15),
MRP  = c(16:20),
PYR  = c(21:25),
RSI  = c(26:30),
SSPI = c(31:35),
STI  = c(0.1, 0.2, 0.3, 0.4, 0.5),
TOL  = c(41:45),
YI   = c(0.6, 0.7, 0.8, 0.9, 1.0),
YSI  = c(0.2, 0.3, 0.4, 0.5, 0.6)
)
WASI(df)

Run the code above in your browser using DataLab