Skip to contents

Prints a result of cacs_run() as a header about the run, two tables of the five rates, and a preview of the rows.

Usage

# S3 method for class 'cacs_run_result'
print(x, ..., n_head = 5, n_tail = 3)

Arguments

x

A cacs_run_result object, as returned by cacs_run().

...

Passed to the print method for tibbles (tibble::print.tbl()) for the preview, such as n, the number of rows to show.

n_head, n_tail

Single numbers that have no effect (n in ... sets the number of rows).

Value

x, invisibly.

Details

Each part of the output starts with a title line:

catchmentACS run result

The time the result was created and the version of catchmentACS that created it, the routing service and the drive times given to cacs_run(), and the routing profile of the drive-time areas. The drive times are the ones given in the call, so when the areas come from precomputed_isochrones the line can name a drive time that no row of the result has. The line "Sites" gives the number of sites with at least one drive-time area (success), the number of sites given to cacs_run() in sites (total), and total minus success, but not below 0 (failed). If precomputed_isochrones has areas for sites that are not in sites, success counts them too, so it can exceed total and failed can miss sites without a drive-time area. When tracts were skipped because they have no area, one more line gives the length of the skipped_geoids attribute, which lists each such tract once for each of its variables.

Top 5 rates (cross-site mean +/- sd)

One row for each of the five rates, highest mean first. The columns are the unweighted mean (mean_estimate) and the standard deviation (sd_estimate) of the rate over all site and drive-time pairs, leaving out missing values, and n, the number of pairs, including those where the rate is missing.

Rates per site

The estimates of the five rates, with one row for each site and drive time. The table is shown when the result has at most getOption("catchmentACS.summary_per_site_max") sites (12 by default). With 0 it is never shown, and with Inf always.

Tibble preview

The rows, printed as a tibble. Before this title, the line "Wall clock" gives the time that cacs_run() took, in seconds. The last line names as_tibble(x), which returns a plain tibble (see as_tibble.cacs_run_result()), and x[], which is the same object and prints in the same way.

The rate tables need the columns variable, estimate, and moe, so they are not shown for the list-column form of the result. Subsets made with [ or with dplyr verbs such as dplyr::filter(), and tables made with dplyr::count() or dplyr::distinct(), keep the class and are printed in the same way, with the header of the whole result. Printing one that has those three columns but no site_id column gives an error. Without the cacs_run_result_metadata attribute, the result is printed as a plain tibble.

Capturing the output

The tables are ordinary printed output, and every other line is an R message written with the cli package. These calls keep different parts:

capture.output(print(x))                    # the tables
capture.output(print(x), type = "message")  # the cli output
testthat::capture_messages(print(x))        # the cli output, in tests
suppressMessages(print(x))                  # prints only the tables

Examples

# A bundled cacs_run() result for a 10-minute area in Birmingham, Alabama
out <- readRDS(system.file("extdata", "visual_walkthrough_fixture.rds",
                           package = "catchmentACS"))$run_result

# One site and one drive time, so the standard deviations are NA
print(out, n = 5)
#> 
#> ── catchmentACS run result ─────────────────────────────────────────────────────
#> Generated at: 2026-05-29 17:15:15
#> Package version: 0.5.0
#> Provider: osrm / car
#> Drive times: 10 min
#> Sites: 1 success / 0 failed / 1 total
#> 
#> ── Top 5 rates (cross-site mean +/- sd) ──
#> 
#> # A tibble: 5 × 4
#>   variable                  mean_estimate sd_estimate     n
#>   <chr>                             <dbl>       <dbl> <int>
#> 1 labor_force_participation        0.649           NA     1
#> 2 poverty_rate                     0.193           NA     1
#> 3 snap_rate                        0.112           NA     1
#> 4 ssi_rate                         0.0504          NA     1
#> 5 unemp_rate                       0.0424          NA     1
#> ── Rates per site ──
#> 
#> # A tibble: 1 × 7
#>   site_id   drive_time_min poverty_rate snap_rate ssi_rate unemp_rate
#>   <chr>              <int>        <dbl>     <dbl>    <dbl>      <dbl>
#> 1 AL_BHM_01             10        0.193     0.112   0.0504     0.0424
#> # ℹ 1 more variable: labor_force_participation <dbl>
#> Wall clock: 0.2s
#> 
#> ── Tibble preview ──
#> 
#> # A tibble: 19 × 27
#>   site_id   drive_time_min ring_topology variable   estimate   moe weight_sum
#>   <chr>              <int> <chr>         <chr>         <dbl> <dbl>      <dbl>
#> 1 AL_BHM_01             10 cumulative    B01003_001   64227. 2133.       23.3
#> 2 AL_BHM_01             10 cumulative    B11001_001   31139. 1067.       23.3
#> 3 AL_BHM_01             10 cumulative    B17001_001   58947. 2112.       23.3
#> 4 AL_BHM_01             10 cumulative    B17001_002   11403. 1373.       23.3
#> 5 AL_BHM_01             10 cumulative    B19013_001   68803. 5658.       23.3
#> # ℹ 14 more rows
#> # ℹ 20 more variables: n_tracts <int>, n_tracts_num <int>, n_tracts_den <int>,
#> #   provider <chr>, profile <chr>, osm_snapshot_date <chr>, acs_year <int>,
#> #   weight_method <chr>, estimand_family <chr>, weight_basis <chr>,
#> #   moe_formula_requested <chr>, moe_formula_effective <chr>,
#> #   moe_fallback <lgl>, moe_fallback_reason <chr>, failure_origin <chr>,
#> #   weight_uncertainty_propagated <lgl>, est_total <dbl>, …
#> ℹ For full output: `as_tibble(x)` or `x[]`