lifeTable_export: Save the Results of One Life Table Analysis

View source: R/lifetable_export.R

lifeTable_exportR Documentation

Save the Results of One Life Table Analysis

Description

Writes all results of one data set into a multi-sheet 'Excel' workbook (<file name>_out.xlsx): the population parameters, the age-stage survival rates, the age-specific rates and, optionally, the survival curve plot.

Usage

lifeTable_export(
  lt,
  results,
  output_path = getwd(),
  plot = NULL,
  keep_tiff = FALSE,
  dpi = 300
)

Arguments

lt

A life_table object returned by lifeTable_read.

results

The result list returned by lifeTable_calculate_all.

output_path

Character; folder the workbook is written to. Defaults to the current working directory.

plot

A ggplot object (usually from lifeTable_plot); if NULL (default) no image is exported.

keep_tiff

Logical; whether to keep the standalone tiff file next to the workbook in addition to the copy embedded in it. Default FALSE, i.e. the tiff is deleted after being embedded.

dpi

Numeric; resolution of the exported image (default 300).

Details

The tiff is written through the internal lt_ggsave(), which enables 'showtext' for the export device and pins the 'showtext' internal dpi to the value the text sizes of lifeTable_plot are calibrated for. The exported figure therefore looks the same in every R session, no matter what 'showtext' settings are left over in the session. If the reproduction-related parameters were skipped (fecundity = FALSE in lifeTable_calculate_all), the corresponding values in the Summary sheet are NA and the sheets "Female fecundity (F_xj)" and "Age-specific fecundity (m_x)" are omitted. If bootstrap results are attached (results$boot <- lifeTable_bootstrap(lt); done automatically by lifeTable_analyze and lifeTable_calculate when bootstrap = TRUE), an extra worksheet "Bootstrap (SE & CI)" with the parameter table (original estimate, bootstrap mean, standard error, percentile confidence interval) is written.

Value

The path of the exported xlsx file (invisibly).

See Also

lifeTable_calculate, lifeTable_plot

Examples

f <- system.file("extdata", "lifetable_example.csv", package = "insectecol")
lt <- lifeTable_read(f)
results <- lifeTable_calculate_all(lt)
lifeTable_export(lt, results, tempdir())

insectecol documentation built on Oct. 5, 2026, 5:08 p.m.