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:
- input validation
- predictor generation
- descriptive statistics
- linear, nonlinear, and mixed models
- model evaluation and ranking
- equation extraction
- prediction
- exploratory graphics
- an interactive Shiny application
During development:
devtools::load_all(".")A typical workflow in leafareaR involves:
- validating the input data;
- generating derived predictors from
LandW; - fitting candidate models;
- evaluating and ranking the fitted models;
- extracting equations and coefficients;
- generating predictions and graphics.
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:
- load the built-in example dataset (
leafarea_sample) with one click; - upload a dataset;
- select predictors for modeling;
- choose model families and model types;
- fit and compare candidate models;
- inspect equations and coefficients;
- export ranked results and graphics.
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.