Writes a creel_estimates or creel_summary object to a CSV or xlsx file.
For CSV, a three-line comment block is prepended containing the estimation
method, variance method, confidence level, and generation timestamp. For
xlsx, the data are written directly (Excel does not support comment rows).
Usage
write_estimates(
x,
path,
format = c("auto", "csv", "xlsx"),
overwrite = FALSE,
...
)Arguments
- x
A
creel_estimatesorcreel_summaryobject.- path
File path for the output. The extension (
.csvor.xlsx) determines the format; alternatively, use theformatargument to override.- format
One of
"csv"(default) or"xlsx". When"csv", a comment header is prepended. When"xlsx",writexl::write_xlsx()is used behind anrlang::check_installed()guard.- overwrite
Logical; if
FALSE(default) an error is raised whenpathalready exists.- ...
Currently unused; reserved for future arguments.
Details
CSV format — The output file begins with comment lines starting with
# that record survey metadata:
# Survey estimates — tidycreel
# Method: Total Effort | Taylor linearization | 95% CI
# Generated: 2024-06-15 09:32:11 UTC
Estimate,SE,CI Lower,CI Upper,N
372.5,13.18,343.8,401.2,14These lines can be skipped when reading back with
utils::read.csv(path, comment.char = "#").
xlsx format — The data are written without a comment header since Excel does not natively support comment rows. Row 1 will be the column headers.
See also
summary.creel_estimates(), write_schedule()
Other "Reporting & Diagnostics":
adjust_nonresponse(),
check_completeness(),
compare_variance(),
flag_outliers(),
season_summary(),
standardize_species(),
summarize_by_angler_type(),
summarize_by_day_type(),
summarize_by_method(),
summarize_by_species_sought(),
summarize_by_trip_length(),
summarize_cws_rates(),
summarize_hws_rates(),
summarize_length_freq(),
summarize_refusals(),
summarize_successful_parties(),
summarize_trips(),
summary.creel_estimates(),
validate_creel_data(),
validate_design(),
validate_incomplete_trips(),
validation_report()
Examples
data("example_counts")
data("example_interviews")
cal <- unique(example_counts[, c("date", "day_type")])
design <- suppressWarnings(
creel_design(cal, date = date, strata = day_type) # nolint
)
design <- suppressWarnings(add_counts(design, example_counts))
design <- suppressWarnings(
add_interviews(
design, example_interviews,
catch = catch_total, effort = hours_fished, trip_status = trip_status
)
)
#> ℹ No `n_anglers` provided — assuming 1 angler per interview.
#> ℹ Pass `n_anglers = <column>` to use actual party sizes for angler-hour
#> normalization.
#> ℹ Added 22 interviews: 17 complete (77%), 5 incomplete (23%)
eff <- suppressWarnings(estimate_effort(design))
tmp <- tempfile(fileext = ".csv")
write_estimates(eff, tmp)
# Read back (skipping comment lines)
out <- utils::read.csv(tmp, comment.char = "#")
out
#> Estimate SE CI.Lower CI.Upper N
#> 1 372.5 13.18 343.8 401.2 14
