get_data: Get data

View source: R/get-data.R

get_dataR Documentation

Get data

Description

Get the data of the last millesime of all the datafiles found in data. All columns are returned as chr (see below).

For private life reason, data returned by DiDo can be secretize (the value is replaced by the string "secret") so readr can't determine data type. You can use convert() to convert number and integer.

get_data cache data before loading it. By default it saves the files in tempdir(). If you downloaded the same data again, il will first try to find it in the cache argument. If you want to cache data between session, don't keep the default but use your own directory.

Usage

get_data(
  data,
  query = list(),
  col_types = cols(.default = "c"),
  concat = TRUE,
  cache = tempdir()
)

Arguments

data

a tibble issued from ⁠datafiles() or a dataframe with two columns ⁠ridandmillesime'.

query

a query to pass to the API to select columns and filter on values.

col_types

how to convert columns, the default is to use char for all columns cols(.default = "c")

concat

TRUE if TRUE, returns a tibble with all data concatenated in one tibble, else returns a list of tibbles.

cache

the directory to cache/save downloaded files. Default is tempdir()

Details

For caching, get_data() will use a reproductible name compose of the datafile identifier (rid) and the stringification of the query passed to get_data() of a query is passed.

Value

If concat is TRUE (default), return a tibble with all data concatenated in one tibble. If concat is FALSE, return a list of tibbles.

get_data() returns only chr columns. Use convert to convert columns to good types.

Examples

# get all columns
datafiles() %>%
  dido_search("drom") %>%
  get_data()
# get only DEPARTEMENT_CODE and ESSENCE_M3 columns
datafiles() %>%
  dido_search("drom") %>%
  get_data(query = c(columns = "DEPARTEMENT_CODE,ESSENCE_M3"))
# get only rows where `DEPARTEMENT_CODE == 971
datafiles() %>%
  dido_search("drom") %>%
  get_data(query = c(DEPARTEMENT_CODE = "eq:971"))
datafiles() %>%
  dido_search("drom") %>%
  get_data(query = c(DEPARTEMENT_CODE = "eq:971"), cache = tempdir())

MTES-MCT/didor documentation built on April 7, 2023, 7:42 a.m.