| Title: | Green Manure Decomposition, Nutrient Release and Crop Response |
|---|---|
| Description: | Tools for analysing green manure and cover crop experiments, for example with Mucuna, sunhemp and dhaincha. Fits single-pool, double-pool and asymptotic litterbag decomposition models and ranks them by the corrected Akaike information criterion, estimates the time to 50 percent mass loss with Monte-Carlo confidence intervals, and quantifies nitrogen, phosphorus, potassium and other nutrient release over time. Further functions compute nutrient inputs, crop uptake, apparent nitrogen recovery and fertilizer nitrogen replacement value, estimate residual effects of green manures on succeeding kharif and rabi crops, link decomposition, nutrient release and crop response in a joint analysis, and generate standardized tables, diagnostic plots and a Word report. |
| Authors: | Anbukkani Perumal [aut, cre, cph], Ramachandran S [aut, cph] |
| Maintainer: | Anbukkani Perumal <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-13 23:35:22 UTC |
| Source: | https://github.com/cran/GreenManureR |
Quantifies the effect of each green manure treatment relative to a control on the yield (or any response) of successive crops, for example a kharif crop followed by a rabi crop.
carryover_effect( data, response = "grain_yield", treatment = "treatment", control = "Control", season = "season", block = "block", strata = NULL, season_levels = NULL, adjust = "holm", level = 0.95 )carryover_effect( data, response = "grain_yield", treatment = "treatment", control = "Control", season = "season", block = "block", strata = NULL, season_levels = NULL, adjust = "holm", level = 0.95 )
data |
Plot-level data frame. |
response |
Column with the response (e.g. grain yield). |
treatment |
Column with treatment labels. |
control |
Label of the control treatment. |
season |
Column identifying the crop or season. |
block |
Column identifying blocks, or |
strata |
Optional columns to analyse separately (e.g. |
season_levels |
Order of seasons in the crop sequence (defaults to order of appearance). |
adjust |
Method passed to |
level |
Confidence level for intervals. |
For every stratum and season the model response ~ block + treatment is
fitted (randomized complete block design; without a block term if
block = NULL). Treatment-versus-control contrasts use the model
estimates and standard errors, with p-values adjusted across treatments
by adjust. The percentage change is the contrast divided by the control
mean; the log response ratio uses the pooled residual variance in a
delta-method standard error. retention_vs_first expresses each seasonal
effect as a percentage of the effect in the first season.
The pooled analysis fits response ~ season:block + treatment + treatment:season across seasons; a significant treatment x season term
indicates that the effect changes between crops. Seasonal variances are
assumed homogeneous, which should be checked. The cumulative effect is the
sum of seasonal contrasts, with a standard error that assumes independence
between seasons and is therefore approximate.
An object of class "gm_carryover": a list with effects
(contrasts per stratum, season and treatment), anova (treatment
F-tests within season), pooled (pooled analysis, or NULL with one
season), cumulative, response and control.
greenmanure_n_balance(), gm_joint_analysis()
co <- carryover_effect(gm_agronomy, response = "grain_yield", strata = "fert_N", season_levels = c("Kharif", "Rabi")) coco <- carryover_effect(gm_agronomy, response = "grain_yield", strata = "fert_N", season_levels = c("Kharif", "Rabi")) co
Fits single-pool, double-pool and asymptotic decay models to litterbag mass-loss data, separately for each group (for example each green manure species), and ranks the models by AICc.
decomp_fit( data, time = "time", mass = "mass", group = NULL, models = c("single", "double", "asymptotic"), mass_scale = c("percent", "fraction") )decomp_fit( data, time = "time", mass = "mass", group = NULL, models = c("single", "double", "asymptotic"), mass_scale = c("percent", "fraction") )
data |
A data frame in long format with one row per litterbag and sampling date. |
time |
Name of the column holding time since incorporation (e.g. days). |
mass |
Name of the column holding the mass remaining. |
group |
Character vector of grouping columns (species, site, ...), or
|
models |
Any of |
mass_scale |
Either |
With M the percentage of the initial mass remaining and t the time
since incorporation, the models are:
single: M = 100 * exp(-k * t)
double: M = 100 * (A * exp(-kf * t) + (1 - A) * exp(-ks * t)), fitted
with ks = r * kf and 0 < r <= 1, so the fast pool can never decay
more slowly than the slow pool.
asymptotic: M = C + (100 - C) * exp(-k * t), where C is the
recalcitrant residue (percent of initial mass).
The initial mass is fixed at 100%, so time-zero observations should be included (or the data expressed relative to the initial mass). Each model is fitted by nonlinear least squares (port algorithm with bounds) from a small grid of starting values, and the best-fitting converged solution is kept.
An object of class "gm_decomp", a list with components
table (one row per group and model with parameters k, k_slow,
pool_A, C_resistant, fit statistics RSS, RMSE, R2, AIC,
AICc, dAICc, Akaike weight, and selected marking the lowest
AICc), fits (the nls objects), data, gcols and groups. For the
double-pool model k is the fast-pool rate and k_slow the slow-pool
rate.
decomp_t50(), nutrient_release()
fit <- decomp_fit(gm_litterbag, time = "time", mass = "mass", group = "treatment") fit fit$table[fit$table$selected, c("treatment", "model", "k", "R2")]fit <- decomp_fit(gm_litterbag, time = "time", mass = "mass", group = "treatment") fit fit$table[fit$table$selected, c("treatment", "model", "k", "R2")]
Solves the fitted decay model for the time at which a proportion p of
the initial mass has been lost (p = 0.5 gives t50), with an optional
Monte-Carlo confidence interval.
decomp_t50( fit, p = 0.5, model = "best", ci = TRUE, nsim = 2000, level = 0.95, seed = 123 )decomp_t50( fit, p = 0.5, model = "best", ci = TRUE, nsim = 2000, level = 0.95, seed = 123 )
fit |
An object returned by |
p |
Proportion lost, strictly between 0 and 1 (0.5 gives t50, 0.95 gives t95). |
model |
|
ci |
Logical; compute the Monte-Carlo interval? |
nsim |
Number of Monte-Carlo draws. |
level |
Confidence level. |
seed |
Integer seed used for the draws. The global random number
state is left unchanged. Use |
The interval is obtained by drawing nsim parameter vectors from a
multivariate normal distribution centred on the estimates with the
covariance matrix of the nls fit, discarding draws outside the
admissible parameter space, and taking quantiles of the resulting times.
If the model never reaches the target (for example an asymptotic model
with a residue above the target), NA is returned.
A data frame with the grouping columns, the model used, p, the
time (column named e.g. t50) and the interval limits lwr and upr.
fit <- decomp_fit(gm_litterbag, group = "treatment") decomp_t50(fit) decomp_t50(fit, p = 0.95, ci = FALSE)fit <- decomp_fit(gm_litterbag, group = "treatment") decomp_t50(fit) decomp_t50(fit, p = 0.95, ci = FALSE)
Simulated field data for a control and three green manures at three
fertilizer N levels, in four blocks, for a kharif crop followed by a rabi
crop. Generated with simulate_greenmanure() (seed 42); the values are
synthetic.
gm_agronomygm_agronomy
A data frame with 96 rows and 10 variables:
Control or green manure species.
Fertilizer N applied (kg/ha).
Block (1-4).
Crop season (Kharif, Rabi).
Green manure dry matter (t/ha).
Green manure N concentration (%).
Yields (t/ha).
N concentrations (%).
Simulated; see data-raw/simulate-data.R.
simulate_greenmanure(), greenmanure_n_balance(),
carryover_effect()
Builds one row per treatment that joins the decomposition rate and t50, the cumulative release of one nutrient by a chosen day, apparent N recovery and the percentage yield response in each season, and reports Spearman rank correlations among these variables.
gm_joint_analysis( decomp, nutrient, nbal, carry, key = "treatment", nutrient_name = "N", at_day = 60, anr_season = NULL, fert_N_level = NULL )gm_joint_analysis( decomp, nutrient, nbal, carry, key = "treatment", nutrient_name = "N", at_day = 60, anr_season = NULL, fert_N_level = NULL )
decomp |
A |
nutrient |
A |
nbal |
A |
carry |
A |
key |
Name of the treatment column shared by all inputs. |
nutrient_name |
Nutrient (as named in |
at_day |
Day at which model-based cumulative release is evaluated. |
anr_season, fert_N_level
|
Optional filters restricting the plots used
to average apparent N recovery: the first |
With only a few treatments (for example three green manure species) the correlations are descriptive only, and a warning is issued when fewer than five rows are available. To draw inference, pool several sites or years.
An object of class "gm_joint": a list with data (the linkage
table) and cor (Spearman correlation matrix, or NULL).
decomp_fit(), nutrient_release(), greenmanure_n_balance(),
carryover_effect()
fit <- decomp_fit(gm_litterbag, group = "treatment") nr <- nutrient_release(gm_litterbag, group = "treatment", biomass = "biomass_tha") nb <- greenmanure_n_balance(gm_agronomy, by = "season") co <- carryover_effect(gm_agronomy, strata = "fert_N") ja <- suppressWarnings( gm_joint_analysis(fit, nr, nb, co, at_day = 60, fert_N_level = 0)) ja$datafit <- decomp_fit(gm_litterbag, group = "treatment") nr <- nutrient_release(gm_litterbag, group = "treatment", biomass = "biomass_tha") nb <- greenmanure_n_balance(gm_agronomy, by = "season") co <- carryover_effect(gm_agronomy, strata = "fert_N") ja <- suppressWarnings( gm_joint_analysis(fit, nr, nb, co, at_day = 60, fert_N_level = 0)) ja$data
Simulated litterbag data for three green manure species, with mass and
nutrient concentrations over 112 days. Generated with
simulate_greenmanure() (seed 42); the values are synthetic.
gm_litterbaggm_litterbag
A data frame with 108 rows and 8 variables:
Green manure species (Mucuna, Sunhemp, Dhaincha).
Litterbag replicate (1-4).
Days after incorporation (0-112).
Dry mass remaining (% of initial).
Nutrient concentrations (% dry weight).
Green manure dry matter incorporated (t/ha).
Simulated; see data-raw/simulate-data.R.
simulate_greenmanure(), decomp_fit(), nutrient_release()
Print, prediction and plotting methods for the objects returned by
decomp_fit(), nutrient_release(), greenmanure_n_balance(),
carryover_effect() and gm_joint_analysis(). Plot methods return
ggplot objects and require the 'ggplot2' package.
## S3 method for class 'gm_decomp' print(x, digits = 4, ...) ## S3 method for class 'gm_decomp' predict(object, times, model = "best", ...) ## S3 method for class 'gm_nutrient' print(x, digits = 3, ...) ## S3 method for class 'gm_nbalance' print(x, digits = 3, ...) ## S3 method for class 'gm_carryover' print(x, digits = 3, ...) ## S3 method for class 'gm_joint' print(x, digits = 3, ...) ## S3 method for class 'gm_decomp' plot(x, y, model = "best", ...) ## S3 method for class 'gm_nutrient' plot(x, y, ...) ## S3 method for class 'gm_nbalance' plot(x, y, ...) ## S3 method for class 'gm_carryover' plot(x, y, ...)## S3 method for class 'gm_decomp' print(x, digits = 4, ...) ## S3 method for class 'gm_decomp' predict(object, times, model = "best", ...) ## S3 method for class 'gm_nutrient' print(x, digits = 3, ...) ## S3 method for class 'gm_nbalance' print(x, digits = 3, ...) ## S3 method for class 'gm_carryover' print(x, digits = 3, ...) ## S3 method for class 'gm_joint' print(x, digits = 3, ...) ## S3 method for class 'gm_decomp' plot(x, y, model = "best", ...) ## S3 method for class 'gm_nutrient' plot(x, y, ...) ## S3 method for class 'gm_nbalance' plot(x, y, ...) ## S3 method for class 'gm_carryover' plot(x, y, ...)
x, object
|
An object returned by one of the package functions. |
digits |
Number of significant digits to print. |
... |
Further arguments (ignored). |
times |
Times (e.g. days) at which to predict mass remaining. |
model |
|
y |
Unused; present for consistency with the |
print methods return x invisibly. predict.gm_decomp()
returns a data frame with the grouping columns, model, time and
pred (predicted mass remaining, %). plot methods return a ggplot
object.
fit <- decomp_fit(gm_litterbag, group = "treatment") predict(fit, times = c(30, 60, 90)) if (requireNamespace("ggplot2", quietly = TRUE)) plot(fit)fit <- decomp_fit(gm_litterbag, group = "treatment") predict(fit, times = c(30, 60, 90)) if (requireNamespace("ggplot2", quietly = TRUE)) plot(fit)
Plot-level nitrogen accounting for green manure experiments, with treatment summaries.
greenmanure_n_balance( data, treatment = "treatment", control = "Control", rep = "block", by = NULL, gm_biomass = "gm_biomass", gm_N = "gm_N", fert_N = "fert_N", grain_yield = "grain_yield", grain_N = "grain_N", straw_yield = "straw_yield", straw_N = "straw_N", nfrv = TRUE )greenmanure_n_balance( data, treatment = "treatment", control = "Control", rep = "block", by = NULL, gm_biomass = "gm_biomass", gm_N = "gm_N", fert_N = "fert_N", grain_yield = "grain_yield", grain_N = "grain_N", straw_yield = "straw_yield", straw_N = "straw_N", nfrv = TRUE )
data |
Plot-level data frame. |
treatment |
Column with the treatment label. |
control |
Label of the treatment without green manure. |
rep |
Column identifying replicates or blocks (not used in the calculations; kept for documentation and future use). |
by |
Optional columns defining strata (e.g. season, site, year). |
gm_biomass, gm_N
|
Columns with green manure dry matter (t/ha) and N concentration (%). |
fert_N |
Column with fertilizer N applied (kg/ha). If absent it is taken as zero. |
grain_yield, grain_N, straw_yield, straw_N
|
Columns with yields (t/ha) and N concentrations (%). Straw columns may be absent. |
nfrv |
Logical; compute the fertilizer N replacement value? |
All quantities are in kg N/ha unless stated otherwise:
N_gm_input: green manure dry matter (t/ha) x 1000 x N percent / 100.
N_uptake: grain plus straw N removal.
N_balance: (green manure N + fertilizer N) minus crop N uptake, an
apparent balance (losses and soil N are not measured).
ANR: apparent N recovery from green manure (percent): (uptake - mean
control uptake at the same stratum and fertilizer N) / green manure N
input x 100.
AE_gmN: additional grain (kg) per kg of green manure N.
NFRV: fertilizer N replacement value, the fertilizer N needed in the
control plots (quadratic response fitted per by stratum, requiring at
least three fertilizer levels) to match the green manure plot yield,
minus the fertilizer N applied. NA when the yield lies outside the
fitted response range.
An object of class "gm_nbalance": a list with plot (plot-level
results), summary (means, standard deviations and standard errors per
stratum, treatment and fertilizer level), by and treatment.
nb <- greenmanure_n_balance(gm_agronomy, by = "season") nb head(nb$summary[, c("season", "treatment", "fert_N", "ANR_mean")])nb <- greenmanure_n_balance(gm_agronomy, by = "season") nb head(nb$summary[, c("season", "treatment", "fert_N", "ANR_mean")])
Writes tables (CSV), figures (PNG) and, if the 'officer' package is installed, a Word report containing all tables and figures for any combination of analysis objects.
greenmanure_report( decomp = NULL, nutrient = NULL, nbal = NULL, carry = NULL, joint = NULL, outdir, docx = TRUE, dpi = 300, digits = 3 )greenmanure_report( decomp = NULL, nutrient = NULL, nbal = NULL, carry = NULL, joint = NULL, outdir, docx = TRUE, dpi = 300, digits = 3 )
decomp, nutrient, nbal, carry, joint
|
Objects returned by
|
outdir |
Directory in which to write the files (required). |
docx |
Logical; also write |
dpi |
Resolution of the PNG figures. |
digits |
Significant digits used in the exported tables. |
Nothing is written unless outdir is supplied; the directory is created
if needed. Figures require 'ggplot2' and the Word report requires
'officer'; when either is missing the corresponding output is skipped
with a message and the remaining outputs are still produced.
Invisibly, a list with tables (data frames) and figures
(file paths).
fit <- decomp_fit(gm_litterbag, group = "treatment") out <- file.path(tempdir(), "gm_report") greenmanure_report(decomp = fit, outdir = out, docx = FALSE) list.files(out)fit <- decomp_fit(gm_litterbag, group = "treatment") out <- file.path(tempdir(), "gm_report") greenmanure_report(decomp = fit, outdir = out, docx = FALSE) list.files(out)
Calculates the percentage of the initial nutrient content remaining in litterbags, fits decay models to each nutrient and reports the time to 50% release and model-based cumulative release at chosen times.
nutrient_release( data, time = "time", mass = "mass", nutrients = c("N", "P", "K"), group = NULL, biomass = NULL, at = c(7, 14, 30, 60, 90), models = c("single", "double", "asymptotic") )nutrient_release( data, time = "time", mass = "mass", nutrients = c("N", "P", "K"), group = NULL, biomass = NULL, at = c(7, 14, 30, 60, 90), models = c("single", "double", "asymptotic") )
data |
Long data frame of litterbag observations including the initial (time zero) sampling. |
time, mass
|
Names of the time and mass-remaining (%) columns. |
nutrients |
Names of the columns holding nutrient concentrations
(% dry weight), e.g. |
group |
Character vector of grouping columns, or |
biomass |
Optional. Name of a column, or a single number, giving the dry-matter input in t/ha. If supplied, nutrient input and release are also reported in kg/ha. |
at |
Times at which model-based cumulative release is reported. |
models |
Models passed to |
Nutrient remaining (% of initial content) is
mass * concentration / initial concentration, where mass is the
percentage of the initial dry mass remaining and the initial concentration
is the group mean at the earliest sampling time (which must therefore be
present in data). Values above 100% indicate net immobilization.
Decay models are fitted with decomp_fit() to the nutrient-remaining
percentages.
An object of class "gm_nutrient": a list with data (long table
with remaining, released and optionally input_kg_ha,
released_kg_ha), fits (a gm_decomp object per nutrient), t50,
release_at, gcols and at.
nr <- nutrient_release(gm_litterbag, nutrients = c("N", "P", "K"), group = "treatment", biomass = "biomass_tha", at = c(14, 30, 60)) nr subset(nr$release_at, nutrient == "N")nr <- nutrient_release(gm_litterbag, nutrients = c("N", "P", "K"), group = "treatment", biomass = "biomass_tha", at = c(14, 30, 60)) nr subset(nr$release_at, nutrient == "N")
Generates synthetic data with the structure expected by the package functions: a litterbag decomposition experiment with three green manure species (Mucuna, sunhemp, dhaincha) and a replicated field experiment with a control, three fertilizer N levels and two successive crops (kharif and rabi). The values are simulated for testing and teaching and do not represent real measurements.
simulate_greenmanure(seed = 42)simulate_greenmanure(seed = 42)
seed |
Integer seed. The global random number state is left
unchanged. Use |
A list with data frames litterbag (see gm_litterbag) and
agronomy (see gm_agronomy).
sim <- simulate_greenmanure(seed = 1) str(sim$litterbag)sim <- simulate_greenmanure(seed = 1) str(sim$litterbag)