read_survey_csv()
View source ↗On this page
Read data.CatL.csv, data.wgt.csv and data.mat.csv from one folder, keeping their row and column order, so that they can be passed to prepare_alscl_data().
Usage
read_survey_csv(folder)
Arguments
| Argument | Default | Description |
|---|---|---|
folder | required | Directory containing data.CatL.csv, data.wgt.csv and data.mat.csv. |
Value
A named list with the numeric tables data.CatL, data.wgt and data.mat, ready for prepare_alscl_data().
Details
The first column contains length-bin labels and subsequent headers contain numeric time labels. Blank cells and NA represent missing values. Numeric text is converted without using factor level codes. Rows and columns retain their original order. The weight and maturity tables must be complete; zeros and missing values of the survey index table are kept. The biological settings are supplied separately, for example with prepare_alscl_data().
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
folder <- tempfile("survey-csv-")
dir.create(folder)
for (nm in c("data.CatL", "data.wgt", "data.mat")) {
write.csv(YTF_example[[nm]], file.path(folder, paste0(nm, ".csv")),
row.names = FALSE)
}
tables <- read_survey_csv(folder)
x <- prepare_alscl_data(tables, fit_args = YTF_example$fit_args,
fit_config = YTF_example$fit_config)
check_alscl_data(x, "acl")$summary