| Title: | Compositional Nutrient Diagnosis for Plant Tissue Analysis |
|---|---|
| Description: | Provides an implementation of Compositional Nutrient Diagnosis (CND) for plant tissue tests. Computes scale invariant simplex filling values(Rd), row-centered log-ratios (CLR), iterative database partitioning via Cate-Nelson procedures, cubic polynomial regression of cumulative variance ratio functions to determine inflection point yield cutoffs, critical CND nutrient imbalance thresholds (r^2) using the chi-square distribution, diagnostic standardized indices (Ix) and automated Cate Nelson scatter partitioning. Includes linear, non-linear, cumulative variance, chi-square and quadrant plotting functions.Methodology and theoretical frameworks are grounded in Parent and Dafir (1992) <doi:10.21273/JASHS.117.2.239> and Khiari et al. (2001) <doi:10.2134/agronj2001.934802x>. |
| Authors: | Blesson B. Varghese [aut, cre], Rohith A K [aut], Anjali S. [aut], Aliya Shirin K S [aut], Hilal Mohamed [aut] |
| Maintainer: | Blesson B. Varghese <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.2 |
| Built: | 2026-10-21 20:56:24 UTC |
| Source: | https://github.com/cran/cndplantanalysis |
Evaluates candidate split points across bivariate diagnostic data (CND vs. Crop Yield)
to automatically determine critical thresholds maximizing the ANOVA Sum of Squares Between groups
() (Nelson & Anderson, 1977; Khiari et al., 2001).
calc_cate_nelson_empirical(diag_data, yield_col = "Yield")calc_cate_nelson_empirical(diag_data, yield_col = "Yield")
diag_data |
Data frame output from |
yield_col |
Character string specifying the yield column name. Default is |
A named list containing:
crit_r2 |
Empirically optimized critical CND |
crit_yield |
Empirically optimized critical yield cutoff. |
{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) auto_thresh <- calc_cate_nelson_empirical(diag_results, yield_col = "Yield") print(auto_thresh) }{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) auto_thresh <- calc_cate_nelson_empirical(diag_results, yield_col = "Yield") print(auto_thresh) }
Fits a cubic polynomial model for each component,
calculates the inflection point yield cutoff (), determines the maximum yield target,
computes the low-yielding population percentage, and returns high-yield (hyp) and
low-yield (lyp) CND norms (Khiari et al., 2001).
cut_off_table(iter_data, lc_data, yield_col, nutrient_cols, digits = 2)cut_off_table(iter_data, lc_data, yield_col, nutrient_cols, digits = 2)
iter_data |
Data frame produced by |
lc_data |
Data frame produced by |
yield_col |
Character string specifying the crop yield column name. |
nutrient_cols |
Character vector specifying selected nutrient names. |
digits |
Numeric integer specifying decimal rounding precision. Default is |
Setting the second derivative of the cubic function to zero yields the inflection point:
The highest inflection point across all components is retained as the minimum yield target.
The mean () and standard deviation () of row-centered log ratios
within the high-yield subpopulation () form the baseline CND norms.
A named list containing two data frames:
cut_off_table |
Polynomial coefficients ( |
norms_table |
CND reference norms containing |
{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) print(cnd_out$cut_off_table) print(cnd_out$ow_yield_percentage) print(cnd_out$norms_table) }{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) print(cnd_out$cut_off_table) print(cnd_out$ow_yield_percentage) print(cnd_out$norms_table) }
Standardizes new plant tissue samples against high-yield CND reference norms
( and ), computing individual CND nutrient indices ()
and the global nutrient imbalance index ().
diagnose_specimen( new_data, norms_table, sample_col, nutrient_cols, yield_col = NULL, digits = 2 )diagnose_specimen( new_data, norms_table, sample_col, nutrient_cols, yield_col = NULL, digits = 2 )
new_data |
Data frame containing new specimen concentrations and sample identifiers. |
norms_table |
Data frame output from |
sample_col |
Character string specifying the sample identifier column name. |
nutrient_cols |
Character vector specifying selected nutrient names. |
yield_col |
Optional character string specifying the yield column name if present in |
digits |
Numeric integer for decimal rounding precision. Default is |
Individual CND indices are calculated as standardized score deviations from high-yield norms:
The global nutrient imbalance index () sums the squared indices across all components:
A data frame containing:
sample_col |
Sample identifiers. |
yield_col |
Crop yield values (if provided). |
nutrient_cols |
Nutrient concentrations. |
Rd |
Residual filling value |
G |
Geometric mean |
Vx |
Row-centered log ratios. |
Ix |
Individual CND nutrient indices. |
r2 |
Global nutrient imbalance index |
{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) print(diag_results) }{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) print(diag_results) }
Iteratively partitions a yield-ordered dataset into two subpopulations
( high-yielding and low-yielding specimens) across steps,
computing the variance ratio function and the cumulative variance
ratio function for each component (Khiari et al., 2001).
iteration_for_hyp(lc_data, yield_col, nutrient_cols, digits = 2)iteration_for_hyp(lc_data, yield_col, nutrient_cols, digits = 2)
lc_data |
Data frame output from |
yield_col |
Character string specifying the crop yield column name. |
nutrient_cols |
Character vector specifying selected nutrient names. |
digits |
Numeric integer specifying decimal rounding precision. Default is |
At each iteration (from to ), the ratio function
is evaluated as:
The cumulative variance ratio function scales the accumulated variance ratios
on a zero to hundred percentage scale:
A data frame containing:
iteration |
Iteration index (1 to |
n1 |
Number of observations in the high-yield subpopulation. |
n2 |
Number of observations in the low-yield subpopulation. |
fi(VX) |
Variance ratio functions for each nutrient and filling value |
Fi(VX) |
Cumulative variance ratio functions ( |
{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) }{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) }
Computes row-centered log ratios () for all components
in the simplex by taking the natural logarithm of each component proportion
divided by the geometric mean (Aitchison, 1986; Parent & Dafir, 1992; Khiari et al., 2001).
log_centered_table(simplex_data, sample_col, yield_col, nutrient_cols)log_centered_table(simplex_data, sample_col, yield_col, nutrient_cols)
simplex_data |
A data frame produced by |
sample_col |
Character string specifying the sample identifier column name. |
yield_col |
Character string specifying the crop yield column name. |
nutrient_cols |
Character vector specifying column names for selected nutrients. |
Row-centered log ratios transform constrained compositional tissue proportions into scale-invariant, unconstrained variables:
for each nutrient and the residual filling value . A fundamental property
of CND row-centered log ratios is that their sum across all components equals zero:
A data frame containing:
sample_col |
Sample identifiers. |
yield_col |
Crop yield values. |
Vx |
Row-centered log ratio columns for each nutrient (e.g., |
{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) }{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) }
A dataset containing leaf sample nutrient information for demonstrating CND methodology. All the nutrients used for analysis should in percentage (%).
plant_leaf_dataplant_leaf_data
An object of class data.frame with 100 rows and 7 columns.
@format A data frame with 100 rows and 7 columns:
Unique identifier for each leaf sample
Yield corresponding to each sample
Nitrogen concentration (%)
Phosphorus concentration (%)
Calcium concentration (%)
Magnesium concentration (%)
Sulfur concentration (%)
@details This dataset is provided as an example for applying CND functions in the package. It includes macronutrients (N, P, Ca, Mg, S), Sample and yield columns.
@examples
data(plant_leaf_data)
#Sorts dataset by yield, computes the residual filling value simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) print(simplex_res)
#Computes scale-invariant row-centered log ratios lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) print(lc_res)
#Iteratively partitions the database iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2)
print(head(iter_res))
#Fits cubic models , calculates inflection point yield cutoffs and extracts high-yield norms. cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2)
print(cnd_out$cut_off_table) print(cnd_out$norms_table)
#Plots upper-tail cumulative chi-square distribution curve and marks theoretical critical threshold. plot_cnd_chisq(nutrient_cols = c("N", "P","Ca","Mg","S"), low_yield_pct = 78, max_r2 = 16)
#Generates a connected scatter plot cumulative function vs. Yield for an #individual nutrient or all nutrients simultaneously. p_cum <- plot_cumulative_variance(iter_res, lc_res, nutrient = "all") print(p_cum)
Generates a publication-ready ggplot2 scatter diagram partitioning crop yield
against the global CND nutrient imbalance index () using Cate Nelson ANOVA quadrant lines
(Khiari et al., 2001). Automatically calculates critical split points if not provided.
plot_cate_nelson( diag_data, crit_r2 = NULL, crit_yield = NULL, yield_col = "Yield" )plot_cate_nelson( diag_data, crit_r2 = NULL, crit_yield = NULL, yield_col = "Yield" )
diag_data |
Data frame output from |
crit_r2 |
Numeric critical CND |
crit_yield |
Numeric critical yield cutoff. If |
yield_col |
Character string specifying the crop yield column name. Default is |
A ggplot object representing the Cate Nelson quadrant scatter diagram.
data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) p_cn <- plot_cate_nelson(diag_results, crit_r2 = 1.4, crit_yield = 6.40)data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) p_cn <- plot_cate_nelson(diag_results, crit_r2 = 1.4, crit_yield = 6.40)
Plots the theoretical upper-tail cumulative chi-square distribution curve for
degrees of freedom and marks the theoretical critical CND nutrient imbalance threshold ()
corresponding to the low-yield subpopulation percentage (Parent et al., 1994; Khiari et al., 2001).
plot_cnd_chisq(nutrient_cols, low_yield_pct, max_r2 = 16, digits = 2)plot_cnd_chisq(nutrient_cols, low_yield_pct, max_r2 = 16, digits = 2)
nutrient_cols |
Character vector of selected nutrient names. |
low_yield_pct |
Numeric percentage of low-yielding population below cutoff (e.g., |
max_r2 |
Numeric maximum value for the x-axis plot range. Default is |
digits |
Numeric integer for decimal rounding precision. Default is |
Because CND indices () are independent unit-normal variables, their sum of squares
follows a chi-square distribution with degrees of freedom:
Mapping the proportion of low-yielding observations as an upper-tail cumulative probability
yields the theoretical critical threshold .
Generates a plot and invisibly returns a list with df, low_yield_pct, and critical_r2.
plot_cnd_chisq(nutrient_cols = c("N", "P","Ca","Mg","S"), low_yield_pct = 78, max_r2 = 16)plot_cnd_chisq(nutrient_cols = c("N", "P","Ca","Mg","S"), low_yield_pct = 78, max_r2 = 16)
Fits a simple linear regression model relating crop yield to the global CND nutrient
imbalance index () based on output from diagnose_specimen (Khiari et al., 2001).
plot_cnd_yield_linear( x = NULL, y = NULL, data = NULL, r2_col = "r2", yield_col = "Yield", critical_r2 = 1.4, x_label = "CND r^2", y_label = "Yield", plot_title = "Linear Yield Trend with CND Imbalance Index" )plot_cnd_yield_linear( x = NULL, y = NULL, data = NULL, r2_col = "r2", yield_col = "Yield", critical_r2 = 1.4, x_label = "CND r^2", y_label = "Yield", plot_title = "Linear Yield Trend with CND Imbalance Index" )
x |
Optional numeric vector of CND r^2 imbalance index values. |
y |
Optional numeric vector of crop yield values. |
data |
Optional data frame containing CND r^2 and yield columns (e.g. output from |
r2_col |
Character string specifying the column name for r^2 when |
yield_col |
Character string specifying the column name for yield when |
critical_r2 |
Optional numeric threshold value at which to extrapolate and annotate yield. Default is |
x_label |
Character string for the x-axis label. Default is |
y_label |
Character string for the y-axis label. Default is |
plot_title |
Character string for the plot title. Default is |
A list containing:
model |
The fitted |
predicted_yield |
Numeric extrapolated yield value at |
plot |
The generated |
data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) linear_result <- plot_cnd_yield_linear( data = diag_results, r2_col = "r2", yield_col = "Yield", critical_r2 = 1.4, y_label = "Yield", plot_title = "Linear Yield Trend with CND Imbalance Index" ) linear_result$predicted_yield summary(linear_result$model) print(linear_result$plot)data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) linear_result <- plot_cnd_yield_linear( data = diag_results, r2_col = "r2", yield_col = "Yield", critical_r2 = 1.4, y_label = "Yield", plot_title = "Linear Yield Trend with CND Imbalance Index" ) linear_result$predicted_yield summary(linear_result$model) print(linear_result$plot)
Fits a non-linear polynomial regression model relating crop yield to the global
CND nutrient imbalance index (r^2) based on output from diagnose_specimen
or direct vector inputs. Predicts and visualizes the extrapolated
yield at a specified critical r^2 threshold with arrow and point annotations.
plot_cnd_yield_nlr( x = NULL, y = NULL, data = NULL, r2_col = "r2", yield_col = "yield", critical_r2 = 9.65, x_label = "CND r^2", y_label = "Yield", plot_title = "Non-Linear Regression: Yield vs. Imbalance Index", poly_degree = 2 )plot_cnd_yield_nlr( x = NULL, y = NULL, data = NULL, r2_col = "r2", yield_col = "yield", critical_r2 = 9.65, x_label = "CND r^2", y_label = "Yield", plot_title = "Non-Linear Regression: Yield vs. Imbalance Index", poly_degree = 2 )
x |
Optional numeric vector of CND r^2 imbalance index values. |
y |
Optional numeric vector of crop yield values. |
data |
Optional data frame containing CND r^2 and yield columns (e.g. output from |
r2_col |
Character string specifying the column name for r^2 when |
yield_col |
Character string specifying the column name for yield when |
critical_r2 |
Numeric threshold value at which to extrapolate and annotate yield. Default is |
x_label |
Character string for the x-axis label. Default is |
y_label |
Character string for the y-axis label. Default is |
plot_title |
Character string for the plot title. Default is |
poly_degree |
Integer specifying the polynomial degree for regression fit. Default is |
A list containing:
model |
The fitted |
predicted_yield |
Numeric extrapolated yield value at |
plot |
The generated |
data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) # Example using diagnose_specimen output data frame nlr_result<- plot_cnd_yield_nlr( data = diag_results, r2_col = "r2", yield_col = "Yield", critical_r2 = 3.23, poly_degree = 2 ) nlr_result$predicted_yield summary(nlr_result$model) print(nlr_result$plot) # Example using direct vector inputs nlr_out2 <- plot_cnd_yield_nlr( x = diag_results$r2, y = diag_results$Yield, critical_r2 = 3.23 )data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) cnd_out <- cut_off_table( iter_data = iter_res, lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S"), digits = 2 ) data(validation_data) diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) # Example using diagnose_specimen output data frame nlr_result<- plot_cnd_yield_nlr( data = diag_results, r2_col = "r2", yield_col = "Yield", critical_r2 = 3.23, poly_degree = 2 ) nlr_result$predicted_yield summary(nlr_result$model) print(nlr_result$plot) # Example using direct vector inputs nlr_out2 <- plot_cnd_yield_nlr( x = diag_results$r2, y = diag_results$Yield, critical_r2 = 3.23 )
Generates a connected scatter plot (line + points) using ggplot2 displaying the
cumulative variance ratio function on the y-axis versus crop yield on the x-axis
for selected nutrients or all nutrients simultaneously (Khiari et al., 2001).
plot_cumulative_variance( iter_data, lc_data, nutrient = "all", yield_col = "Yield" )plot_cumulative_variance( iter_data, lc_data, nutrient = "all", yield_col = "Yield" )
iter_data |
Data frame output from |
lc_data |
Data frame output from |
nutrient |
Character string specifying the nutrient to plot (e.g., |
yield_col |
Character string specifying the crop yield column name. Default is |
A ggplot object representing the connected scatter plot.
data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S")) p_cum <- plot_cumulative_variance(iter_res, lc_res, nutrient = "all")data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) lc_res <- log_centered_table( simplex_data = simplex_res, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S") ) iter_res <- iteration_for_hyp( lc_data = lc_res, yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S")) p_cum <- plot_cumulative_variance(iter_res, lc_res, nutrient = "all")
Rearranges a plant tissue database by crop yield in descending order, calculates
the scale-invariant filling value () for the -dimensional simplex (),
and computes the geometric mean () across all components
(Parent & Dafir, 1992; Khiari et al., 2001).
simplex_table(data, sample_col, yield_col, nutrient_cols)simplex_table(data, sample_col, yield_col, nutrient_cols)
data |
A data frame containing sample identifiers, crop yield values, and nutrient concentration percentages. |
sample_col |
Character string specifying the column name containing sample identifiers. |
yield_col |
Character string specifying the column name containing crop yield values. |
nutrient_cols |
Character vector specifying column names for the selected
nutrients (e.g., |
In Compositional Nutrient Diagnosis (CND), plant tissue composition forms a
-dimensional simplex () composed of nutrient proportions
including nutrients and a residual filling value ():
The geometric mean () of all components is computed as:
A data frame arranged in descending order of crop yield containing:
sample_col |
Original sample identifiers. |
yield_col |
Crop yield values. |
nutrient_cols |
Selected nutrient concentration percentages. |
Rd |
Residual filling value ( |
G |
Geometric mean across all |
{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S")) }{ data(plant_leaf_data) simplex_res <- simplex_table( data = plant_leaf_data, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S")) }
A dataset containing leaf sample nutrient information for demonstrating CND norms validation methodology. All the nutrients used for analysis should in percentage (%).
validation_datavalidation_data
An object of class data.frame with 20 rows and 7 columns.
@format A data frame with 20 rows and 7 columns:
Unique identifier for each leaf sample
Yield corresponding to each sample
Nitrogen concentration (%)
Phosphorus concentration (%)
Calcium concentration (%)
Magnesium concentration (%)
Sulfur concentration (%)
@details This dataset is provided as an example dataset for standardizing its row-centered log ratio against the high-yield norms to obtain the CND index and to compute global nutrient imbalance index. The dataset includes following columns:Sample,Yield and macronutrients (N, P, Ca, Mg, S).
@examples
data(validation_data)
#Standardizes new crop samples against norms to calculate individual CND nutrient indices and global imbalance index. diag_results <- diagnose_specimen( new_data = validation_data, norms_table = cnd_out$norms_table, sample_col = "Sample", yield_col = "Yield", nutrient_cols = c("N", "P","Ca","Mg","S")) print(diag_results)
#Evaluates candidate split pairs via ANOVA grid search to maximize between sum of squares for automated Cate–Nelson thresholding. auto_thresh <- calc_cate_nelson_empirical(diag_results, yield_col = "Yield") auto_thresh
#Generates a quadrant scatter plot (Yield vs. ) with automated or specified Cate–Nelson threshold lines.
plot_cate_nelson(diag_results)
#If there are specified values then use function in following way p_cn <- plot_cate_nelson(diag_results, crit_r2 = 1.4, crit_yield = 6.40) print(p_cn)
#Fits a non-linear polynomial regression (ggplot2) relating crop yield to CND indices.
regplot<- plot_cnd_yield_nlr(
data = diag_results,
r2_col = "r2", # Name of your r^2 column
yield_col = "Yield", # Name of your yield column
critical_r2 = 3.23, # Custom critical value
y_label = "Yield", # Y-axis label
plot_title = "Yield vs CND Imbalance Index")
regplot
#Fits a linear regression model (ggplot2) relating crop yield to CND indices.
plot <- plot_cnd_yield_linear(
data = diag_results,
r2_col = "r2", # Column name for r^2
yield_col = "Yield", # Column name for yield
critical_r2 = 3.23, # Critical value
y_label = "Yield vs CND Imbalane Index")