Tools for leaf area estimation based on leaf length, leaf width,
and observed leaf area. The package supports data validation, predictor
generation, descriptive statistics, exploratory graphics, scatterplot
matrices, linear models, nonlinear models, mixed models, model
evaluation, ranking, equation generation, prediction, export of results
and plots, and an interactive 'shiny' application. Methods implemented
in the package are aligned with non-destructive allometric workflows
described by Ribeiro et al. (2024)
leafareaR is an R package for leaf area modeling, evaluation,
prediction, and visualization based on leaf length (L), leaf width
(W), and observed leaf area (LA).
The package supports:
During development:
devtools::load_all(".")
A typical workflow in leafareaR involves:
L and W;The package includes a sample dataset named leafarea_sample.
data("leafarea_sample", package = "leafareaR")
leafarea_sample[1:6, c("L", "W", "LA")]
Optional grouping variables such as block, species, and genotype
may also be present in the example dataset.
dat <- la_validate_input(leafarea_sample)
dat2 <- la_create_derived(
dat,
variables = c("LW", "L2", "W2", "L3", "W3", "L_plus_W")
)
fit_linear <- la_fit_linear_models(dat2)
length(fit_linear$models)
met_linear <- la_evaluate_linear_models(fit_linear)
ranked_linear <- la_rank_models(met_linear)
la_top_models(ranked_linear, n = 5)
best_linear <- fit_linear$models[[ranked_linear$model_id[1]]]
la_build_equation(best_linear)
pred <- la_predict_top_ranked(
ranked_table = ranked_linear,
fit_object = fit_linear,
rank_position = 1,
newdata = dat2[1:10, ]
)
pred[1:6, c("LA", "LA_pred", "residual")]
la_plot_scatter(dat2, x = "LW", y = "LA")
vals <- la_linear_fitted_values(fit_linear, ranked_linear$model_id[1])
la_plot_observed_predicted(
observed = vals$observed,
predicted = vals$fitted,
model_name = ranked_linear$model_id[1]
)
The same general workflow can be applied to nonlinear and mixed models.
# Nonlinear example
fit_nonlinear <- la_fit_nonlinear_models(dat2, models = c("power_LW"))
# Mixed example
fit_mixed <- la_fit_mixed_models(dat2, group_var = "species")
leafareaR also provides an interactive Shiny application.
run_leafareaR_app()
With the app, users can:
leafarea_sample) with one click;leafareaR provides a practical workflow for leaf area analysis, from
data validation to model comparison, equation reporting, prediction, and
visualization.
The package can be used in scripted analyses as well as through its Shiny interface.