Turns a creel_estimates result into a plain table that dplyr, tidyr and
ggplot2 accept, so a result can be filtered, joined, bound to other results
or written out like any other data.
Usage
# S3 method for class 'creel_estimates'
as_tibble(x, ..., metadata = TRUE)
# S3 method for class 'creel_estimates'
as.data.frame(x, ..., metadata = TRUE)Arguments
- x
A
creel_estimatesobject, as returned by theestimate_*()functions.- ...
Unused by
as_tibble(); passed toas.data.frame()byas.data.frame().- metadata
If
TRUE(the default), add the metadata columns described below. IfFALSE, return the estimates table alone.
Value
A tibble (as_tibble()) or data frame (as.data.frame()) with one
row per estimate: the grouping columns, estimate, se, ci_lower,
ci_upper, n (NA where the estimator reports no sample size) and
any further columns the estimator reports. With
metadata = TRUE these columns follow:
methodThe estimation method, e.g.
"total".estimatorThe rate estimator asked for, e.g.
"ratio-of-means". Present only on results whose function takes an estimator choice.variance_method"taylor","bootstrap"or"jackknife".conf_levelConfidence level of
ci_lowerandci_upper.effort_targetWhat an effort or total estimate totals over, e.g.
"sampled_days". Present only on results that have one.unitThe unit of
estimate, e.g."angler-hours".NAmeans the unit could not be derived from the data, not that there is none.
Standard-error components (x$se_components) are not returned as
columns, for the reason given in tidy.creel_estimates(): read them from
the object or from print().
A grouping column with the same name as a metadata column (a by column
called unit, say) is an error rather than being overwritten; use
metadata = FALSE and read the metadata from the object.
Details
A creel_estimates object keeps what the numbers mean (the method, the unit,
the confidence level) beside its table rather than in attributes on it,
because an ordinary select() or filter() drops attributes without a
word. The conversion copies that metadata into columns, so it travels with
every row and is visible if it is dropped.
See also
Other "Reporting & Diagnostics":
adjust_nonresponse(),
check_completeness(),
compare_variance(),
flag_outliers(),
season_summary(),
standardize_species(),
summarize_boat_composition(),
summarize_by_angler_type(),
summarize_by_county(),
summarize_by_day_type(),
summarize_by_method(),
summarize_by_species_sought(),
summarize_by_trip_length(),
summarize_by_zip(),
summarize_cws_rates(),
summarize_hws_rates(),
summarize_length_freq(),
summarize_refusals(),
summarize_successful_parties(),
summarize_trips(),
summary.creel_estimates(),
tidy.creel_estimates(),
validate_creel_data(),
validate_design(),
validate_incomplete_trips(),
validation_report(),
write_estimates()
Examples
design <- creel_design(example_calendar, date = date, strata = day_type)
counts <- prep_counts_daily_effort(example_counts,
date = date, strata = day_type, daily_effort = effort_hours
)
design <- add_counts(design, counts)
est <- estimate_effort(design, by = day_type)
tibble::as_tibble(est)
#> # A tibble: 2 × 13
#> day_type estimate se se_between se_within ci_lower ci_upper n method
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <chr>
#> 1 weekday 171. 9.67 9.67 0 150. 192. 10 total
#> 2 weekend 202. 8.95 8.95 0 182. 221. 4 total
#> # ℹ 4 more variables: variance_method <chr>, conf_level <dbl>,
#> # effort_target <chr>, unit <chr>
as.data.frame(est, metadata = FALSE)
#> day_type estimate se se_between se_within ci_lower ci_upper n
#> 1 weekday 170.6 9.673790 9.673790 0 149.5226 191.6774 10
#> 2 weekend 201.9 8.946321 8.946321 0 182.4076 221.3924 4
