| Type: | Package |
| Title: | Green Manure Decomposition, Nutrient Release and Crop Response |
| Version: | 0.1.0 |
| 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. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.0.0) |
| Imports: | stats, utils, withr |
| Suggests: | ggplot2, officer, knitr, rmarkdown, testthat (≥ 3.0.0) |
| VignetteBuilder: | knitr |
| LazyData: | true |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.1 |
| NeedsCompilation: | no |
| Packaged: | 2026-10-01 09:25:45 UTC; root |
| Author: | Anbukkani Perumal [aut, cre, cph], Ramachandran S [aut, cph] |
| Maintainer: | Anbukkani Perumal <anbueconomic@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-13 15:00:18 UTC |
GreenManureR: Green Manure Decomposition, Nutrient Release and Crop Response
Description
Tools for green manure and cover crop experiments (Mucuna, sunhemp, dhaincha and others): litterbag decomposition models, nutrient release, nitrogen balance, residual (carry-over) effects on succeeding crops, a joint analysis linking the three, and standardized reporting.
Main functions
-
decomp_fit()fits single-pool, double-pool and asymptotic decay models. -
decomp_t50()estimates the time to 50% (or any other %) mass loss. -
nutrient_release()quantifies N, P, K and other nutrient release. -
greenmanure_n_balance()computes N inputs, crop uptake and balances. -
carryover_effect()quantifies residual effects on kharif and rabi crops. -
gm_joint_analysis()links decomposition, release and crop response. -
greenmanure_report()writes standardized tables, figures and a report.
Example data sets (simulated) are provided as gm_litterbag and
gm_agronomy; see also simulate_greenmanure().
Author(s)
Maintainer: Anbukkani maintainer@example.org [copyright holder]
Residual (carry-over) effects of green manure on succeeding crops
Description
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.
Usage
carryover_effect(
data,
response = "grain_yield",
treatment = "treatment",
control = "Control",
season = "season",
block = "block",
strata = NULL,
season_levels = NULL,
adjust = "holm",
level = 0.95
)
Arguments
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. |
Details
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.
Value
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.
See Also
greenmanure_n_balance(), gm_joint_analysis()
Examples
co <- carryover_effect(gm_agronomy, response = "grain_yield",
strata = "fert_N",
season_levels = c("Kharif", "Rabi"))
co
Fit litterbag decomposition models
Description
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.
Usage
decomp_fit(
data,
time = "time",
mass = "mass",
group = NULL,
models = c("single", "double", "asymptotic"),
mass_scale = c("percent", "fraction")
)
Arguments
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 |
Details
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 withks = r * kfand0 < r <= 1, so the fast pool can never decay more slowly than the slow pool.asymptotic:
M = C + (100 - C) * exp(-k * t), whereCis 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.
Value
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.
See Also
decomp_t50(), nutrient_release()
Examples
fit <- decomp_fit(gm_litterbag, time = "time", mass = "mass",
group = "treatment")
fit
fit$table[fit$table$selected, c("treatment", "model", "k", "R2")]
Time to a given percentage of mass (or nutrient) loss
Description
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.
Usage
decomp_t50(
fit,
p = 0.5,
model = "best",
ci = TRUE,
nsim = 2000,
level = 0.95,
seed = 123
)
Arguments
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 |
Details
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.
Value
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.
See Also
Examples
fit <- decomp_fit(gm_litterbag, group = "treatment")
decomp_t50(fit)
decomp_t50(fit, p = 0.95, ci = FALSE)
Simulated two-season agronomic data
Description
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.
Usage
gm_agronomy
Format
A data frame with 96 rows and 10 variables:
- treatment
Control or green manure species.
- fert_N
Fertilizer N applied (kg/ha).
- block
Block (1-4).
- season
Crop season (Kharif, Rabi).
- gm_biomass
Green manure dry matter (t/ha).
- gm_N
Green manure N concentration (%).
- grain_yield, straw_yield
Yields (t/ha).
- grain_N, straw_N
N concentrations (%).
Source
Simulated; see data-raw/simulate-data.R.
See Also
simulate_greenmanure(), greenmanure_n_balance(),
carryover_effect()
Joint analysis of decomposition, nutrient release and crop response
Description
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.
Usage
gm_joint_analysis(
decomp,
nutrient,
nbal,
carry,
key = "treatment",
nutrient_name = "N",
at_day = 60,
anr_season = NULL,
fert_N_level = NULL
)
Arguments
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 |
Details
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.
Value
An object of class "gm_joint": a list with data (the linkage
table) and cor (Spearman correlation matrix, or NULL).
See Also
decomp_fit(), nutrient_release(), greenmanure_n_balance(),
carryover_effect()
Examples
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$data
Simulated litterbag decomposition data
Description
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.
Usage
gm_litterbag
Format
A data frame with 108 rows and 8 variables:
- treatment
Green manure species (Mucuna, Sunhemp, Dhaincha).
- rep
Litterbag replicate (1-4).
- time
Days after incorporation (0-112).
- mass
Dry mass remaining (% of initial).
- N, P, K
Nutrient concentrations (% dry weight).
- biomass_tha
Green manure dry matter incorporated (t/ha).
Source
Simulated; see data-raw/simulate-data.R.
See Also
simulate_greenmanure(), decomp_fit(), nutrient_release()
Methods for GreenManureR objects
Description
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.
Usage
## 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, ...)
Arguments
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 |
Value
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.
Examples
fit <- decomp_fit(gm_litterbag, group = "treatment")
predict(fit, times = c(30, 60, 90))
if (requireNamespace("ggplot2", quietly = TRUE)) plot(fit)
Nitrogen inputs, crop uptake and apparent balance
Description
Plot-level nitrogen accounting for green manure experiments, with treatment summaries.
Usage
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
)
Arguments
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? |
Details
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 perbystratum, requiring at least three fertilizer levels) to match the green manure plot yield, minus the fertilizer N applied.NAwhen the yield lies outside the fitted response range.
Value
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.
See Also
Examples
nb <- greenmanure_n_balance(gm_agronomy, by = "season")
nb
head(nb$summary[, c("season", "treatment", "fert_N", "ANR_mean")])
Standardized tables, diagnostic plots and Word report
Description
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.
Usage
greenmanure_report(
decomp = NULL,
nutrient = NULL,
nbal = NULL,
carry = NULL,
joint = NULL,
outdir,
docx = TRUE,
dpi = 300,
digits = 3
)
Arguments
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. |
Details
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.
Value
Invisibly, a list with tables (data frames) and figures
(file paths).
Examples
fit <- decomp_fit(gm_litterbag, group = "treatment")
out <- file.path(tempdir(), "gm_report")
greenmanure_report(decomp = fit, outdir = out, docx = FALSE)
list.files(out)
Nutrient release from decomposing green manure residues
Description
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.
Usage
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")
)
Arguments
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 |
Details
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.
Value
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.
See Also
Examples
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")
Simulate litterbag and two-season agronomic data
Description
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.
Usage
simulate_greenmanure(seed = 42)
Arguments
seed |
Integer seed. The global random number state is left
unchanged. Use |
Value
A list with data frames litterbag (see gm_litterbag) and
agronomy (see gm_agronomy).
Examples
sim <- simulate_greenmanure(seed = 1)
str(sim$litterbag)