Write the result tables of run_pipeline() (or of a single step such as
calc_fcr()) to CSV files.
write_results(
x,
dir = ".",
farm = "farm",
date = Sys.Date(),
bom = TRUE,
verbose = 1
)Result of run_pipeline(), or of clean_weight(),
calc_adg(), calc_adfi() or calc_fcr().
Folder to write to (created if needed). Default: working directory.
Farm or station code used as file name prefix.
Date in the file names. Default: today.
Write a UTF-8 byte order mark (for Excel). Default TRUE.
0 (silent), 1 (summary, default).
Invisibly, a data.table with table, file and rows.
For a run_pipeline() result the files are:
fcr: one row per pig with ADG, ADFI, FCR and confidence flags;
by_bin: feed, gain and FCR per body weight class;
daily_feed: daily feed intake (recorded, corrected, imputed);
daily_weight: daily body weight (observed, filled and fitted);
weight_pigs: weight checks of every pig;
feed_model: coefficients of the feed intake correction model;
removed: removed pigs with step and reason;
settings: the QC settings used.
For a single step, its per_pig, daily and removed tables (and
by_bin, model or summary when present) are written.
res <- run_pipeline(nedap, verbose = 0)
out <- write_results(res, dir = file.path(tempdir(), "results"), farm = "demo")
#> ✔ Wrote 9 files to /tmp/Rtmp93iRXT/results
out
#> table file rows
#> <char> <char> <int>
#> 1: fcr /tmp/Rtmp93iRXT/results/demo_fcr_20261030.csv 29
#> 2: by_bin /tmp/Rtmp93iRXT/results/demo_by_bin_20261030.csv 258
#> 3: daily_feed /tmp/Rtmp93iRXT/results/demo_daily_feed_20261030.csv 2820
#> 4: daily_weight /tmp/Rtmp93iRXT/results/demo_daily_weight_20261030.csv 2607
#> 5: weight_pigs /tmp/Rtmp93iRXT/results/demo_weight_pigs_20261030.csv 30
#> 6: feed_model /tmp/Rtmp93iRXT/results/demo_feed_model_20261030.csv 14
#> 7: summary /tmp/Rtmp93iRXT/results/demo_summary_20261030.csv 14
#> 8: removed /tmp/Rtmp93iRXT/results/demo_removed_20261030.csv 1
#> 9: settings /tmp/Rtmp93iRXT/results/demo_settings_20261030.csv 43
unlink(file.path(tempdir(), "results"), recursive = TRUE)