On this page

Read the sheets data.CatL, data.wgt and data.mat of a workbook with the optional readxl package, stopping at cells that hold Excel error values.

Usage

read_survey_excel(file)

Arguments

ArgumentDefaultDescription
filerequired

Path to an existing workbook with sheets data.CatL, data.wgt and data.mat.

Value

A named list with the numeric tables data.CatL, data.wgt and data.mat.

Details

Requires the optional readxl package. Sheet names must match exactly. The first column is the length-bin label; remaining headers are numeric time labels. The reader applies the same value and alignment checks as read_survey_csv(), keeps the zero and missing cells of the survey index table, and neither infers biological settings nor fills missing time steps.

Only blank cells and NA denote missing values. A cell that holds an Excel error value, such as #DIV/0! or #N/A from a formula, is an error that names the sheet and the cells; readxl would otherwise import it as a missing value and the observation would be left out of the likelihood without a message. This check applies to the .xlsx and .xlsm formats; cells of a workbook in the older .xls format cannot be checked in this way.

Additional details from R help

Only blank cells and NA are missing values. A cell that holds an Excel error value, such as ⁠#DIV/0!⁠ or ⁠#N/A⁠ from a formula, is an error, because readxl would otherwise import it as a missing value and the observation would be left out of the likelihood without a message. The error names the sheet and the cells. This check reads the workbook file directly and applies to the .xlsx and .xlsm formats; cells of a workbook in the older .xls format cannot be checked in this way.

Examples

Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.

Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
# Optional dependency: install.packages("readxl")
# Replace this path with your workbook.
if (file.exists("survey.xlsx")) {
  tables <- read_survey_excel("survey.xlsx")
  # Supply biology for your own stock in fit_args before fitting.
  names(tables)
}

See also

Search documentation