Skip to content

cran/leafareaR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leafareaR

leafareaR

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

Installation

During development:

devtools::load_all(".")

Typical workflow

A typical workflow in leafareaR involves:

  1. validating the input data;
  2. generating derived predictors from L and W;
  3. fitting candidate models;
  4. evaluating and ranking the fitted models;
  5. extracting equations and coefficients;
  6. generating predictions and graphics.

Example dataset

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.

Input validation

dat <- la_validate_input(leafarea_sample)

Predictor generation

dat2 <- la_create_derived(
  dat,
  variables = c("LW", "L2", "W2", "L3", "W3", "L_plus_W")
)

Linear models

fit_linear <- la_fit_linear_models(dat2)
length(fit_linear$models)

Model evaluation and ranking

met_linear <- la_evaluate_linear_models(fit_linear)
ranked_linear <- la_rank_models(met_linear)
la_top_models(ranked_linear, n = 5)

Equations

best_linear <- fit_linear$models[[ranked_linear$model_id[1]]]
la_build_equation(best_linear)

Prediction

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")]

Graphics

Scatter plot

la_plot_scatter(dat2, x = "LW", y = "LA")

Observed versus predicted

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]
)

Nonlinear and mixed models

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")

Shiny application

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.

Summary

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.

About

❗ This is a read-only mirror of the CRAN R package repository. leafareaR — Leaf Area Modeling, Evaluation, and Prediction. Homepage: https://github.com/agrobioestat/leafareaR Report bugs for this package: https://github.com/agrobioestat/leafareaR/issues

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages