Learn R Programming

istatR (version 0.1.0)

get_data: Retrieve data from an ISTAT dataset

Description

Fetches data from an ISTAT dataset using the currently set filters. The data is returned as a tibble with the TIME_PERIOD column converted to Date format and sorted in ascending order.

Usage

get_data(
  dataset,
  start_period = NULL,
  end_period = NULL,
  last_n_observations = NULL
)

Value

A tibble containing the requested data with columns including:

DATAFLOW

Dataset identifier

FREQ

Frequency

TIME_PERIOD

Time period (as Date)

OBS_VALUE

Observation value

...

Additional dimension and metadata columns

Arguments

dataset

An istat_dataset object with filters set

start_period

Optional start date for filtering (format: YYYY-MM-DD or YYYY)

end_period

Optional end date for filtering (format: YYYY-MM-DD or YYYY)

last_n_observations

Optional integer to get only the last N observations

Examples

Run this code
if (FALSE) {
# Create and configure dataset
ds <- istat_dataset("139_176")
ds <- set_filters(ds,
  FREQ = "M",
  TIPO_DATO = c("ISAV", "ESAV"),
  PAESE_PARTNER = "WORLD"
)

# Get all data
data <- get_data(ds)

# Get data for a specific time range
data <- get_data(ds, start_period = "2020-01-01", end_period = "2023-12-31")

# Get only the last 12 observations
data <- get_data(ds, last_n_observations = 12)
}

Run the code above in your browser using DataLab