| Title: | Diagnostic Systems for Plant Nutrient Analysis (DRIS, MDRIS, PASS) |
|---|---|
| Description: | Provides implementations of the Diagnosis and Recommendation Integrated System (DRIS), the Modified DRIS (MDRIS), and the Plant Analysis with Standardized Scores (PASS) approaches for nutrient diagnosis in crops. These methods allow quantitative evaluation of nutrient imbalances using ratio-based indices and standardized scores, supporting improved fertilizer use efficiency and crop management decisions. The DRIS method is described in Walworth, J.L. and Sumner, M.E. (1987) <doi:10.1007/978-1-4612-4682-4_4>. The MDRIS approach is detailed in Beverly, R.B. (1987) <doi:10.1080/01904168709363672>. The PASS method combining DRIS and sufficiency ranges is presented in Baldock, J.O. and Schulte, E.E. (1996) <doi:10.2134/agronj1996.00021962008800030015x>. |
| Authors: | Blesson B. Varghese [aut, cre], Mubashir Sadiq V [aut], Deepthi C [aut], Sowmiya Saravanan [aut], Aparna Mohan V [aut] |
| Maintainer: | Blesson B. Varghese <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.1 |
| Built: | 2026-09-26 23:07:15 UTC |
| Source: | https://github.com/cran/drisdiagnostics |
Subsets a plant tissue dataset by a specified grouping factor (such as leaf age, soil type, crop variety, or geographic region) and runs the standard Beaufils DRIS diagnostic workflow independently for each factor level. It compiles individual diagnostic tables for each sub-group and generates a master summary table containing mean nutrient indices, the overall Nutrient Balance Index (NBI) computed directly from the group means, and a sorted nutrient requirement order to facilitate comparative agronomic evaluations across varying environmental or management conditions.
calculate_dris_by_group( data, dris_norms, nutrient_cols, filter_col, sample_col = "Sample", hyp_only = TRUE )calculate_dris_by_group( data, dris_norms, nutrient_cols, filter_col, sample_col = "Sample", hyp_only = TRUE )
data |
A data frame containing crop nutrient concentration columns, the grouping factor column,
and the |
dris_norms |
A data frame of calibrated reference norms returned by |
nutrient_cols |
A character vector specifying the exact names of the nutrient columns in |
filter_col |
A character string representing the name of the column in |
sample_col |
A character string specifying the column name containing the sample identifiers
in |
hyp_only |
A logical value. If |
A list containing two diagnostic components:
grouped_tables |
A named list of individual compiled diagnostic tables (data frames) for each unique level of the grouping factor. |
mean_summary_table |
A master summary data frame containing the mean index values for each
nutrient, the overall group NBI (sum of absolute values of the mean indices), and the sorted
|
set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Age = rep(c("Young", "Medium", "Old"), length.out = 20), Yield = runif(20, 2, 5), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) # Split populations processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) # Calculate DRIS norms dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) # Grouped DRIS diagnostics grouped_results <- calculate_dris_by_group( data = processed_data, dris_norms = dris_norms, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg"), filter_col = "Age", sample_col = "Sample", hyp_only = TRUE )set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Age = rep(c("Young", "Medium", "Old"), length.out = 20), Yield = runif(20, 2, 5), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) # Split populations processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) # Calculate DRIS norms dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) # Grouped DRIS diagnostics grouped_results <- calculate_dris_by_group( data = processed_data, dris_norms = dris_norms, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg"), filter_col = "Age", sample_col = "Sample", hyp_only = TRUE )
Performs standard Diagnosis and Recommendation Integrated System (DRIS) calculations for plant tissue samples. It computes individual function values for each optimal ratio using the symmetrical Beaufils formulas, derives individual relative nutrient indices by averaging these function values with appropriate sign conventions and computes the overall Nutrient Balance Index (NBI) as the sum of absolute index values to measure general nutritional balance.
calculate_dris_diagnostics( data, dris_norms, nutrient_cols, sample_col = "Sample", hyp_only = TRUE )calculate_dris_diagnostics( data, dris_norms, nutrient_cols, sample_col = "Sample", hyp_only = TRUE )
data |
A data frame containing the original plant sample dataset to be diagnosed. |
dris_norms |
A data frame of calibrated norms returned by |
nutrient_cols |
A character vector specifying the names of the selected nutrients to evaluate. |
sample_col |
A character string specifying the column name containing the sample identifiers.
Defaults to |
hyp_only |
A logical value. If |
A list containing four diagnostic components:
nutrient_tables |
A list of individual data frames (one for each nutrient) detailing sample ratios, calculated function values, and final indices with a summary Mean row. |
formulas |
A list of character strings representing the final algebraic formulas used to compile the index for each nutrient. |
compiled_table |
A master summary data frame containing the final relative index values and overall Nutrient Balance Index (NBI) for each sample, with an overall Mean row appended at the bottom. |
raw_indices |
A numeric matrix containing unrounded, raw index values for subsequent statistical modeling or graphing. |
set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) diagnostics_results <- calculate_dris_diagnostics( data = processed_data, dris_norms = dris_norms, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg"), sample_col = "Sample" ) print(diagnostics_results$compiled_table)set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) diagnostics_results <- calculate_dris_diagnostics( data = processed_data, dris_norms = dris_norms, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg"), sample_col = "Sample" ) print(diagnostics_results$compiled_table)
Computes descriptive statistics for both high-yielding (HYP) and low-yielding (LYP) crop subpopulations across all possible bi-variate nutrient expressions, including ratio forms (A/B, B/A) and product forms (A*B). To determine which expression is the most agronomically sensitive, the function compares the variances of the two subpopulations using a variance ratio test (Sa/Sb) and evaluates statistical significance via a standard F-test. The nutrient expression that maximizes this variance ratio is flagged as optimal, establishing the baseline diagnostic norm.
calculate_dris_norms(data, nutrient_cols)calculate_dris_norms(data, nutrient_cols)
data |
A data frame containing nutrient columns and a "population_category" column. |
nutrient_cols |
A character vector containing the names of the nutrient columns. |
A data frame containing calculated population statistics (means, variances, standard deviations,
and coefficients of variation) for both HYP and LYP groups across all combinations, alongside
variance ratios (Sa_Sb), F-test p-values, and a selection indicator ("Optimal")
flagging the expression with the largest variance ratio.
set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) print(dris_norms)set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) print(dris_norms)
This function takes a tissue sample dataset and pre-calculated MDRIS norms, and computes:
Ratio-Based MDRIS indices (I_R) using the unified symmetrical logarithmic equation.
Log-Concentration Indices (J_log_r) evaluating nutrients on an absolute log scale.
Direct Concentration Indices (K_r) evaluating nutrients directly on raw scales.
calculate_mdris_diagnostics( data, mdris_norms, nutrient_cols, sample_col = "Sample" )calculate_mdris_diagnostics( data, mdris_norms, nutrient_cols, sample_col = "Sample" )
data |
A data frame of plant tissue analysis to diagnose. |
mdris_norms |
The list returned by |
nutrient_cols |
A character vector containing the names of the selected nutrients. |
sample_col |
Character string representing the column name of the sample identifier. |
A list containing:
weighted_deviations: A data frame of calculated WDR/S values for each sample.
compiled_table: A master data frame containing MDRIS indices, J_log_r values, K_r values and corresponding diagnostic rankings.
set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), Zn = runif(20, 0.001, 0.01), B = runif(20, 0.0005, 0.002) ) mdris_norms <- calculate_mdris_norms( data = my_crop_data, nutrient_cols = c("N", "P", "K", "Zn", "B") ) mdris_results <- calculate_mdris_diagnostics( data = my_crop_data, mdris_norms = mdris_norms, nutrient_cols = c("N", "P", "K", "Zn", "B"), sample_col = "Sample" ) print(mdris_results$compiled_table)set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), Zn = runif(20, 0.001, 0.01), B = runif(20, 0.0005, 0.002) ) mdris_norms <- calculate_mdris_norms( data = my_crop_data, nutrient_cols = c("N", "P", "K", "Zn", "B") ) mdris_results <- calculate_mdris_diagnostics( data = my_crop_data, mdris_norms = mdris_norms, nutrient_cols = c("N", "P", "K", "Zn", "B"), sample_col = "Sample" ) print(mdris_results$compiled_table)
This function computes both log-concentration norms and log-ratio norms for the entire population as proposed by Beverly (1987). Unlike traditional DRIS, MDRIS norms are computed for the entire population database without splitting into high/low-yielding groups, as the log-transformation stabilizes variances across different yield levels.
calculate_mdris_norms(data, nutrient_cols)calculate_mdris_norms(data, nutrient_cols)
data |
A data frame containing raw nutrient concentrations (dry matter percentage). |
nutrient_cols |
A character vector containing the names of the nutrient columns. |
A list containing:
nutrient_norms: Data frame of individual nutrient statistics (Raw Mean, Raw SD, Log Mean, Log SD).
ratio_norms: Data frame of log-transformed ratio statistics (Expression, Log_Mean, Log_SD).
set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), Zn = runif(20, 0.001, 0.01), B = runif(20, 0.0005, 0.002) ) mdris_norms <- calculate_mdris_norms( data = my_crop_data, nutrient_cols = c("N", "P", "K", "Zn", "B") ) print(mdris_norms)set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), Zn = runif(20, 0.001, 0.01), B = runif(20, 0.0005, 0.002) ) mdris_norms <- calculate_mdris_norms( data = my_crop_data, nutrient_cols = c("N", "P", "K", "Zn", "B") ) print(mdris_norms)
This function implements the hybrid PASS diagnostic engine of Baldock and Schulte (1996) using data frame inputs for INI and DNI norms. It is highly robust and avoids R index-stripping issues.
calculate_pass_analysis(data, ini_norms, dni_norms, sample_col = "Sample")calculate_pass_analysis(data, ini_norms, dni_norms, sample_col = "Sample")
data |
A data frame containing tissue concentration columns for the crop. |
ini_norms |
A data frame containing columns: |
dni_norms |
A data frame containing columns: |
sample_col |
Character string representing the column name of the sample identifier. |
A list containing:
compiled_table: A master data frame containing calculated indices, PASS YI, and recommendations.
raw_ini: Numeric matrix of calculated raw INI values.
raw_dni: Numeric matrix of calculated raw DNI values.
set.seed(123) # Tissue samples to be diagnosed my_corn_samples <- data.frame( Sample = paste0("Corn_", 1:10), N = runif(10, 2.5, 3.5), P = runif(10, 0.20, 0.40), K = runif(10, 1.80, 2.60), S = runif(10, 0.15, 0.30), Ca = runif(10, 0.40, 0.90), Mg = runif(10, 0.20, 0.50) ) # Independent Nutrient Index (INI) norms: critical level (CL), SD, and # whether the nutrient participates in the "common" DNI calculations ini_norms <- data.frame( nutrient = c("N", "P", "K", "S", "Ca", "Mg"), CL = c(3.00, 0.30, 2.20, 0.22, 0.65, 0.35), SD = c(0.25, 0.04, 0.20, 0.03, 0.10, 0.05), group = c("common", "common", "common", "rare", "rare", "rare"), stringsAsFactors = FALSE ) # Dependent Nutrient Index (DNI) norms: mean and SD for each nutrient ratio dni_norms <- data.frame( ratio = c("N/P", "P/N", "N/K", "K/N", "P/K", "K/P"), mean = c(10.00, 0.10, 1.36, 0.74, 0.136, 7.33), SD = c(1.20, 0.02, 0.15, 0.08, 0.020, 0.90), stringsAsFactors = FALSE ) # Run the PASS analysis pass_report <- calculate_pass_analysis( data = my_corn_samples, ini_norms = ini_norms, dni_norms = dni_norms, sample_col = "Sample" ) print(pass_report$compiled_table)set.seed(123) # Tissue samples to be diagnosed my_corn_samples <- data.frame( Sample = paste0("Corn_", 1:10), N = runif(10, 2.5, 3.5), P = runif(10, 0.20, 0.40), K = runif(10, 1.80, 2.60), S = runif(10, 0.15, 0.30), Ca = runif(10, 0.40, 0.90), Mg = runif(10, 0.20, 0.50) ) # Independent Nutrient Index (INI) norms: critical level (CL), SD, and # whether the nutrient participates in the "common" DNI calculations ini_norms <- data.frame( nutrient = c("N", "P", "K", "S", "Ca", "Mg"), CL = c(3.00, 0.30, 2.20, 0.22, 0.65, 0.35), SD = c(0.25, 0.04, 0.20, 0.03, 0.10, 0.05), group = c("common", "common", "common", "rare", "rare", "rare"), stringsAsFactors = FALSE ) # Dependent Nutrient Index (DNI) norms: mean and SD for each nutrient ratio dni_norms <- data.frame( ratio = c("N/P", "P/N", "N/K", "K/N", "P/K", "K/P"), mean = c(10.00, 0.10, 1.36, 0.74, 0.136, 7.33), SD = c(1.20, 0.02, 0.15, 0.08, 0.020, 0.90), stringsAsFactors = FALSE ) # Run the PASS analysis pass_report <- calculate_pass_analysis( data = my_corn_samples, ini_norms = ini_norms, dni_norms = dni_norms, sample_col = "Sample" ) print(pass_report$compiled_table)
A dataset containing DRIS nutrient ratio norms used in the PASS method.
dni_normsdni_norms
A data frame with 11 rows and 3 columns:
Nutrient ratio (e.g., N/P, K/Ca)
Mean value of the ratio
Standard deviation of the ratio
These DRIS norms are taken from Baldock and Schulte (1996) and are used together with initial norms to generate PASS diagnostics.
data(dni_norms) head(dni_norms)data(dni_norms) head(dni_norms)
Extracts the optimal diagnostic expressions identified in the norms calibration step and calculates their exact ratio values for each sample in the high-yielding reference subpopulation (HYP). This function provides a structured reference table summarizing baseline healthy ratios, appending critical summary statistics (arithmetic means, variances, standard deviations, and coefficients of variation) as summary rows at the bottom of the table.
generate_hyp_ratios_table(data, dris_norms, sample_col = "Sample")generate_hyp_ratios_table(data, dris_norms, sample_col = "Sample")
data |
A data frame containing the crop tissue and population category columns. |
dris_norms |
A data frame returned by |
sample_col |
Character string representing the column name of the sample identifier. |
A character data frame where rows represent individual high-yielding samples and columns
represent the calculated optimal ratio expressions, with appended summary rows labeled
"Mean", "Variance", "SD", and "CV" at the bottom.
set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) hyp_ratios_results <- generate_hyp_ratios_table( data = processed_data, dris_norms = dris_norms, sample_col = "Sample" ) print(hyp_ratios_results)set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) hyp_ratios_results <- generate_hyp_ratios_table( data = processed_data, dris_norms = dris_norms, sample_col = "Sample" ) print(hyp_ratios_results)
A dataset containing initial nutrient norms used in the PASS (Plant Analysis with Standardized Scores) method.
ini_normsini_norms
A data frame with 12 rows and 4 columns:
Nutrient name
Critical level value
Standard deviation
Grouping category
These initial norms are taken from Baldock and Schulte (1996) and are used in combination with DRIS norms to compute PASS scores.
data(ini_norms) head(ini_norms)data(ini_norms) head(ini_norms)
A dataset containing nutrient concentrations from leaf samples used to demonstratenPASS calculation.
my_corn_samplesmy_corn_samples
A data frame with 3 rows and 12 columns:
Unique identifier for each leaf sample
Nitrogen concentration (%)
Phosphorus concentration (%)
Potassium concentration (%)
Calcium concentration (%)
Magnesium concentration (%)
Sulfur concentration (%)
Zinc concentration (mg/kg)
Boron concentration (mg/kg)
Copper concentration (mg/kg)
Manganese concentration (mg/kg)
Iron concentration (mg/kg)
These leaf samples are used as example data for running PASS analyses.
data(my_corn_samples) data(ini_norms) data(dni_norms) # Run the PASS analysis pass_report <- calculate_pass_analysis( data = my_corn_samples, ini_norms = ini_norms, dni_norms = dni_norms, sample_col = "Sample" ) # View the master diagnostic compiled table print(pass_report$compiled_table)data(my_corn_samples) data(ini_norms) data(dni_norms) # Run the PASS analysis pass_report <- calculate_pass_analysis( data = my_corn_samples, ini_norms = ini_norms, dni_norms = dni_norms, sample_col = "Sample" ) # View the master diagnostic compiled table print(pass_report$compiled_table)
A dataset containing leaf sample information for demonstrating the Diagnosis and Recommendation Integrated System (DRIS) and Modified DRIS (MDRIS) methods.
my_crop_datamy_crop_data
A data frame with 250 rows and 15 columns:
Unique identifier for each leaf sample
Nitrogen concentration (%)
Phosphorus concentration (%)
Potassium concentration (%)
Calcium concentration (%)
Magnesium concentration (%)
Sulfur concentration (%)
Iron concentration (mg/kg)
Manganese concentration (mg/kg)
Copper concentration (mg/kg)
Zinc concentration (mg/kg)
Boron concentration (mg/kg)
Yield corresponding to each sample
Age of the plant from which the leaf was taken
Soil pH of the sample location
This dataset is provided as an example for applying DRIS and MDRIS functions in the package. It includes macronutrients (N, P, K, Ca, Mg, S), micronutrients (Fe, Mn, Cu, Zn, B), yield, plant age, and soil pH.
# Load the dataset data(my_crop_data) # Split data into HYP and LYP using different methods. Use any one of the method. processed_data_per <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 75 ) processed_data_abs <- split_populations( data = my_crop_data, yield_col = "Yield", method = "absolute", value = 3.2 ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "mean_sd", value = 2/3 ) # Generate DRIS norms dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N","P","K","S","Ca","Mg") ) print(dris_norms) # Generate HYP ratios table hyp_ratios_results <- generate_hyp_ratios_table( data = processed_data, dris_norms = dris_norms, sample_col = "Sample" ) print(hyp_ratios_results, row.names = FALSE) # Run DRIS diagnostics diagnostics_results <- calculate_dris_diagnostics( data = processed_data, dris_norms = dris_norms, nutrient_cols = c("N","P","K","S","Ca","Mg"), sample_col = "Sample" ) diagnostics_results # Grouped DRIS results grouped_results <- calculate_dris_by_group( data = processed_data, dris_norms = dris_norms, nutrient_cols = c("N","P","K","S","Ca","Mg"), filter_col = "Age", sample_col = "Sample", hyp_only = FALSE ) grouped_results # Nutrient sufficiency ranges ranges_table <- sufficiency_ranges( data = processed_data, nutrient_cols = c("N","P","K","Zn","B") ) # Tri-axial DRIS wheel plot plot_dris_norms_wheel( dris_norms = dris_norms, ratios_to_plot = c("P/N","N/K","P/K") ) # Calibrate MDRIS norms mdris_norms <- calculate_mdris_norms( data = processed_data, nutrient_cols = c("N","P","K","Zn","B") ) # Run MDRIS diagnostics mdris_results <- calculate_mdris_diagnostics( data = processed_data, mdris_norms = mdris_norms, nutrient_cols = c("N","P","K","Zn","B"), sample_col = "Sample" ) print(mdris_results$compiled_table, row.names = FALSE)# Load the dataset data(my_crop_data) # Split data into HYP and LYP using different methods. Use any one of the method. processed_data_per <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 75 ) processed_data_abs <- split_populations( data = my_crop_data, yield_col = "Yield", method = "absolute", value = 3.2 ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "mean_sd", value = 2/3 ) # Generate DRIS norms dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N","P","K","S","Ca","Mg") ) print(dris_norms) # Generate HYP ratios table hyp_ratios_results <- generate_hyp_ratios_table( data = processed_data, dris_norms = dris_norms, sample_col = "Sample" ) print(hyp_ratios_results, row.names = FALSE) # Run DRIS diagnostics diagnostics_results <- calculate_dris_diagnostics( data = processed_data, dris_norms = dris_norms, nutrient_cols = c("N","P","K","S","Ca","Mg"), sample_col = "Sample" ) diagnostics_results # Grouped DRIS results grouped_results <- calculate_dris_by_group( data = processed_data, dris_norms = dris_norms, nutrient_cols = c("N","P","K","S","Ca","Mg"), filter_col = "Age", sample_col = "Sample", hyp_only = FALSE ) grouped_results # Nutrient sufficiency ranges ranges_table <- sufficiency_ranges( data = processed_data, nutrient_cols = c("N","P","K","Zn","B") ) # Tri-axial DRIS wheel plot plot_dris_norms_wheel( dris_norms = dris_norms, ratios_to_plot = c("P/N","N/K","P/K") ) # Calibrate MDRIS norms mdris_norms <- calculate_mdris_norms( data = processed_data, nutrient_cols = c("N","P","K","Zn","B") ) # Run MDRIS diagnostics mdris_results <- calculate_mdris_diagnostics( data = processed_data, mdris_norms = mdris_norms, nutrient_cols = c("N","P","K","Zn","B"), sample_col = "Sample" ) print(mdris_results$compiled_table, row.names = FALSE)
Visualizes DRIS index values using a horizontal diverging bar chart. Negative index values indicate relative nutrient deficiency, whereas positive index values indicate relative nutrient excess.
plot_dris_diverging_bar(indices, sample_name = "Sample")plot_dris_diverging_bar(indices, sample_name = "Sample")
indices |
A named numeric vector containing DRIS index values.
The names of the vector should correspond to nutrient names. Names ending
in |
sample_name |
A character string specifying the sample name to display
in the plot title. Defaults to |
A ggplot object representing a horizontal diverging bar chart
of DRIS indices, with nutrients classified as deficient (negative values)
or excessive (positive values).
indices <- c( N_index = -15.4, P_index = -8.2, K_index = 12.6, Ca_index = 5.3 ) plot_dris_diverging_bar( indices = indices, sample_name = "Sample 1" )indices <- c( N_index = -15.4, P_index = -8.2, K_index = 12.6, Ca_index = 5.3 ) plot_dris_diverging_bar( indices = indices, sample_name = "Sample 1" )
Projects the calculated Z-score deviations of the low-yielding population (LYP) relative to the high-yielding population (HYP) norms on a classic concentric tri-axial balance wheel diagram. The function extracts descriptive statistics for exactly three selected ratio expressions, projects their Cartesian coordinate points at 120-degree radial intervals. The visual boundaries (representing the balanced zone at 2/3 SD radius and the imbalanced zone at 4/3 SD radius) allow agronomists to instantly diagnose nutrient balance and predict qualitative deficiency or excess dynamics.
plot_dris_norms_wheel(dris_norms, ratios_to_plot)plot_dris_norms_wheel(dris_norms, ratios_to_plot)
dris_norms |
A data frame of calibrated reference norms and statistics returned by
|
ratios_to_plot |
A character vector of exactly three ratio expressions present in
|
A ggplot object representing a fully annotated, concentric tri-axial
DRIS balance wheel with directional nutrient deficiency and excess indicators.
set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) plot_dris_norms_wheel( dris_norms = dris_norms, ratios_to_plot = c("P/N", "N/K", "P/K") )set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) dris_norms <- calculate_dris_norms( data = processed_data, nutrient_cols = c("N", "P", "K", "S", "Ca", "Mg") ) plot_dris_norms_wheel( dris_norms = dris_norms, ratios_to_plot = c("P/N", "N/K", "P/K") )
Categorizes crop sample tissue records into high-yielding (HYP) and low-yielding (LYP) subpopulations based on a designated economic or yield threshold. This partitioning is a fundamental preprocessing step in DRIS allowing the calculation of baseline nutritional norms and standard deviation diagnostics exclusively from the healthy, high-yielding reference cohort.
split_populations( data, yield_col, method = c("mean_sd", "percentile", "absolute"), value = NULL )split_populations( data, yield_col, method = c("mean_sd", "percentile", "absolute"), value = NULL )
data |
A data frame containing plant tissue nutrient concentrations and crop yield values or economic parameter. |
yield_col |
Character string representing the column name of the yield variable in |
method |
Character string specifying the mathematical cutoff method. Must be one of
|
value |
Numeric threshold value matching the selected |
The original data frame data with an appended factor column named
"population_category" containing levels "HYP" (High-Yielding Population)
and "LYP" (Low-Yielding Population).
set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) # Split populations using a custom percentile value processed_data_per <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 75 ) # Split populations using an absolute yield threshold of 3.2 processed_data_abs <- split_populations( data = my_crop_data, yield_col = "Yield", method = "absolute", value = 3.2 ) # Split populations using a custom standard deviation multiplier processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "mean_sd", value = 2/3 )set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), S = runif(20, 0.1, 0.4), Ca = runif(20, 0.5, 2), Mg = runif(20, 0.2, 0.8) ) # Split populations using a custom percentile value processed_data_per <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 75 ) # Split populations using an absolute yield threshold of 3.2 processed_data_abs <- split_populations( data = my_crop_data, yield_col = "Yield", method = "absolute", value = 3.2 ) # Split populations using a custom standard deviation multiplier processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "mean_sd", value = 2/3 )
This function calculates the sufficiency ranges for each nutrient in the High-Yielding Population (HYP) based on standard deviation thresholds (4/3 SD and 8/3 SD).
sufficiency_ranges(data, nutrient_cols)sufficiency_ranges(data, nutrient_cols)
data |
A data frame containing the crop tissue and population category columns (after running split_populations()). |
nutrient_cols |
A character vector containing the names of the nutrient columns. |
Classification rules:
Deficient: < mean - (8/3) * SD
Low: mean - (8/3) * SD to mean - (4/3) * SD
Optimum: mean - (4/3) * SD to mean + (4/3) * SD
High: mean + (4/3) * SD to mean + (8/3) * SD
Excessive: > mean + (8/3) * SD
A data frame containing calculated sufficiency ranges for each nutrient with columns: Nutrient, Mean, SD, Deficient, low, optimum, high and excessive values.
set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), Zn = runif(20, 0.001, 0.01), B = runif(20, 0.0005, 0.002) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) # Generate the nutrient sufficiency ranges table ranges_table <- sufficiency_ranges( data = processed_data, nutrient_cols = c("N", "P", "K", "Zn", "B") ) print(ranges_table)set.seed(123) my_crop_data <- data.frame( Sample = paste0("S", 1:20), Yield = c( 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4, 2.0, 2.1, 2.2, 2.3, 2.4, 4.0, 4.1, 4.2, 4.3, 4.4 ), N = runif(20, 2, 4), P = runif(20, 0.2, 0.5), K = runif(20, 1.5, 3), Zn = runif(20, 0.001, 0.01), B = runif(20, 0.0005, 0.002) ) processed_data <- split_populations( data = my_crop_data, yield_col = "Yield", method = "percentile", value = 50 ) # Generate the nutrient sufficiency ranges table ranges_table <- sufficiency_ranges( data = processed_data, nutrient_cols = c("N", "P", "K", "Zn", "B") ) print(ranges_table)