sidra_query: Build a SIDRA query without downloading values

View source: R/query.R

sidra_queryR Documentation

Build a SIDRA query without downloading values

Description

Constructs and validates a SIDRA values URL. This is useful for inspecting a request or passing it to sidra_plan() before any values are downloaded.

Usage

sidra_query(
  x,
  variable = "allxp",
  period = "last",
  geo = "Brazil",
  geo.filter = NULL,
  classific = "all",
  category = "all",
  header = TRUE,
  format = 4,
  digits = "default",
  api = NULL,
  value_type = c("numeric", "character", "both"),
  geo_view = NULL,
  include_extinct = FALSE
)

Arguments

x

A numeric SIDRA table code. It may be omitted when api is used.

variable

A vector of variable codes. The special selections "all" and "allxp" are also accepted.

period

A character vector of period codes, "all", or a single named value such as c(last = 12) or c(first = 5).

geo

A character vector with geographic aliases or nNN level codes. Aliases and codes are case-insensitive.

geo.filter

A list of geographic filters corresponding to geo. Names may be aliases or nNN codes and are case-insensitive.

classific

A vector of classification codes.

category

"all" or a list of categories for each classification.

header

Logical. Should the API include its header record?

format

An integer from 1 to 4 controlling descriptor fields.

digits

"default", "max", or an integer from 0 to 9.

api

A relative SIDRA API path or complete official values URL. When supplied, the other URL-building arguments are ignored.

value_type

Preferred value representation for a later collection: "numeric", "character", or "both". It does not change the URL.

geo_view

Optional numeric SIDRA territorial-view code. Territorial views (G) cannot be combined with geo or geo.filter (N).

include_extinct

Logical. Add ⁠/u/y⁠ to an N query so extinct territorial units may be returned. It cannot be used with geo_view.

Value

A list of class sidra_query with stable url, header, and parameters components. No values are downloaded.

See Also

get_sidra() and sidra_plan()

Examples

query <- sidra_query(
  1612,
  variable = 214,
  period = "2021",
  geo = "n1",
  classific = "c81",
  category = list(2702)
)
query

sidrar documentation built on Sept. 18, 2026, 9:14 a.m.