
Read a schedule file into a validated creel_schedule object
Source:R/schedule-io.R
read_schedule.RdReads a CSV or xlsx schedule file produced by write_schedule() (or
hand-built in Excel) and returns a validated creel_schedule object ready
for use with creel_design().
Value
A creel_schedule object with columns:
date(Date)day_type(character)period_id(integer, if present)p_period(numeric, if present): the probability each worked period was drawn for its day. Every row with a period on a sampled day must carry one in (0, 1]; a missing, non-numeric or out-of-range value is an error, because the period could not be expanded to the day. A file withperiod_idbut nop_periodcolumn (written before the column existed) is read asp_period = 1, with a warning, when every sampled day carries the same periods (each was worked every day); if the periods differ between days they were drawn, and it is an error.shift_start,shift_end(character "HH:MM", if present)shift_hours(numeric, if present)day_start(character "HH:MM", if present): when each survey day begins; shift times are read on that clocksampled(logical, if present)
Details
The format is detected from the file extension. All columns are read as text
first, then coerce_schedule_columns() applies type coercion – the same
logic runs regardless of format so that Excel-reformatted dates and serial
numbers are handled consistently.
Examples
sched <- generate_schedule(
"2024-06-01", "2024-08-31",
n_periods = 2,
sampling_rate = c(weekday = 0.3, weekend = 0.6),
seed = 42
)
tmp <- tempfile(fileext = ".csv")
write_schedule(sched, tmp)
sched2 <- read_schedule(tmp)
inherits(sched2, "creel_schedule")
#> [1] TRUE