View source: R/stability_analysis.R
stability_analysis | R Documentation |
This function performs stability analysis for multiple traits across different environments using Eberhart and Russell's regression model provided by the 'metan' package. It computes ANOVA tables and regression parameters for assessing genotype stability.
stability_analysis(
data,
genotype_col,
environment_col,
replication_col,
trait_cols
)
data |
A data frame containing the dataset with required columns. |
genotype_col |
Character. Name of the genotype column. |
environment_col |
Character. Name of the environment column. |
replication_col |
Character. Name of the replication column. |
trait_cols |
A vector of trait column names (response variables). |
A list containing results for each trait:
'anova': The ANOVA table for each trait.
'regression': Regression parameters for stability analysis.
Eberhart, S. A., & Russell, W. A. (1966). "Stability Parameters for Comparing Varieties". Crop Science, 6(1), 36–40. doi:10.2135/cropsci1966.0011183X000600010011x
if (!requireNamespace("metan", quietly = TRUE)) {
install.packages("metan")
}
library(metan)
# Simulated dataset
set.seed(123)
data <- data.frame(
Genotype = rep(c("G1", "G2", "G3"), each = 12),
Environment = rep(c("E1", "E2", "E3", "E4"), times = 9),
Replication = rep(1:3, times = 12),
Trait1 = c(rnorm(36, 50, 5)),
Trait2 = c(rnorm(36, 150, 10)),
Trait3 = c(rnorm(36, 250, 15))
)
results <- stability_analysis(
data = data,
genotype_col = "Genotype",
environment_col = "Environment",
replication_col = "Replication",
trait_cols = c("Trait1", "Trait2", "Trait3")
)
print(results$Trait1$anova)
print(results$Trait1$regression)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.