Skip to contents

Answers set and summary questions about a table – which item codes it contains, which response values occur, how many rows each item has – using server-side aggregate queries rather than exporting the table. This matters for large tables: computing the item set of a 68-million-row table with irw_fetch() downloads all 68 million rows, while irw_table_sets() returns the same answer in seconds and does not consume the Redivis export quota.

Usage

irw_table_sets(name, source = "core", per_item = FALSE)

Arguments

name

Character vector of one or more IRW table names. Several names run the same queries once per table, still without an export, so this is the way to sweep many tables.

source

Character. Data source: "core" (default), "nom", "sim", or "comp".

per_item

Logical. If TRUE, also return a per-item summary (row count, response minimum, maximum, and number of distinct response values). One extra query; the result has one row per distinct item. Defaults to FALSE.

Value

For a single name, a list with elements:

table

Fully qualified Redivis reference for the table.

n_rows

Total number of rows.

items

Sorted character vector of distinct item values.

resp

Sorted vector of distinct resp values, numeric when all values are numeric and character otherwise. "NA" and empty strings are treated as missing, matching irw_fetch().

per_item

Data frame of per-item summaries, or NULL when per_item = FALSE.

For several names, a named list of those lists, one per table, in the order given. Each element is exactly what the single-name call returns.

Examples

if (FALSE) { # \dontrun{
sets <- irw_table_sets("rosenberg_selfesteem")
sets$items
sets$resp

irw_table_sets("condon_2024_sapa_personality", per_item = TRUE)$per_item

# Several tables at once: no export, one set of queries per table
sweep <- irw_table_sets(c("rosenberg_selfesteem", "environment_ltm"))
lengths(lapply(sweep, `[[`, "items"))
} # }