Skip to contents

This function downloads data from URLs such as https://movilidad-opendata.mitma.es/estudios_basicos/por-distritos/viajes/ficheros-diarios/2024-03/20240301_Viajes_distritos.csv.gz if the file does not exist in the data directory.

Usage

get_od(
  data_dir = get_data_dir(),
  subdir = "estudios_basicos/por-distritos/viajes/ficheros-diarios",
  date_regex = "2024030[1-2]",
  read_fun = duckdb::tbl_file
)

Arguments

data_dir

The directory where the data is stored.

subdir

The subdirectory where the data is stored.

date_regex

The regular expression to match the date of the data to download.

read_fun

The function to read the data. Defaults to duckdb::tbl_file.

Value

The local path of the downloaded file (download_od), or a data frame with the origin-destination data (get_od).

Examples

# Download the origin-destination data for the first two days of March 2024
if (FALSE) {
od_20240301_20240302 = get_od(date_regex = "2024-03-0[1-2]")
}