| Title: | Access to Datasets from Insper Cidades |
|---|---|
| Description: | Provides tools to discover, download, and cite datasets from Insper Cidades, hosted on the Insper Dataverse repository. Lists datasets and their logical resources, downloads data directly into R, links each dataset to its replication project, and generates academic citations from repository metadata. |
| Authors: | Vinicius Oike [aut, cre] (ORCID: <https://orcid.org/0009-0005-8015-9189>), Insper Cidades [cph, fnd] |
| Maintainer: | Vinicius Oike <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.5.0 |
| Built: | 2026-10-12 15:49:52 UTC |
| Source: | https://github.com/inspercidades/inspercidados |
Fetches metadata from Insper Dataverse and returns a formatted citation. The citation is printed to the console and returned invisibly as a character string.
cite_dataset(dataset, format = c("text", "bibtex", "ris"))cite_dataset(dataset, format = c("text", "bibtex", "ris"))
dataset |
A dataset identifier: alias, bare DOI, or DOI URL
(see |
format |
Citation format. One of |
A character string containing the formatted citation (invisible).
# Plain-text citation cite_dataset("pemob_anual") # BibTeX cite_dataset("pemob_anual", format = "bibtex") # RIS (Zotero, Mendeley, EndNote) cite_dataset("pemob_anual", format = "ris")# Plain-text citation cite_dataset("pemob_anual") # BibTeX cite_dataset("pemob_anual", format = "bibtex") # RIS (Zotero, Mendeley, EndNote) cite_dataset("pemob_anual", format = "ris")
Downloads a registered dataset into R as a tibble or sf object. Identify
the dataset by its short alias; use get_dataverse() for a DOI or URL.
get_dataset( dataset, ..., resource = NULL, year = NULL, format = NULL, docs = FALSE )get_dataset( dataset, ..., resource = NULL, year = NULL, format = NULL, docs = FALSE )
dataset |
A registered dataset alias, e.g. |
... |
Must be empty. Arguments after |
resource |
The name of a logical resource within the registered
dataset. When |
year |
An integer or character year used to filter files when a dataset
contains several annual files (e.g. |
format |
An optional file format, such as |
docs |
Logical. If |
A Dataverse deposit may contain several logical resources, each distributed
in several formats. Use resource to select the logical dataset and
format to select its representation. Deposits with one resource, or a
declared default, need neither argument.
When format is omitted, spatial resources prefer GeoPackage and GeoJSON;
other resources prefer RDS, Parquet, delimited text, and Excel. Formats that
need an uninstalled suggested package are skipped.
When docs = FALSE (default): a tibble or sf
object with the "doi" attribute set. When docs = TRUE: a named list
with elements data and docs.
# By alias embarques <- get_dataset("embarques_mensais") # Pick one year from a multi-year dataset pemob_2023 <- get_dataset("pemob_anual", year = 2023) # Pick a resource and an explicit format pontos <- get_dataset( "qualidade_ar_mare", resource = "pontos", format = "gpkg" ) # Return the data with its documentation result <- get_dataset("embarques_mensais", docs = TRUE) result$docs # Spatial datasets return an sf object faixa_azul <- get_dataset("faixa_azul_sp")# By alias embarques <- get_dataset("embarques_mensais") # Pick one year from a multi-year dataset pemob_2023 <- get_dataset("pemob_anual", year = 2023) # Pick a resource and an explicit format pontos <- get_dataset( "qualidade_ar_mare", resource = "pontos", format = "gpkg" ) # Return the data with its documentation result <- get_dataset("embarques_mensais", docs = TRUE) result$docs # Spatial datasets return an sf object faixa_azul <- get_dataset("faixa_azul_sp")
Downloads any deposit on Insper Dataverse, registered or not. Copy the DOI or the landing-page URL from Insper Dataverse and paste it straight into R.
get_dataverse( x, filename = NULL, file_pattern = NULL, year = NULL, files = FALSE )get_dataverse( x, filename = NULL, file_pattern = NULL, year = NULL, files = FALSE )
x |
A DOI ( |
filename, file_pattern, year
|
Optional selectors passed to the same
file-picking logic used by |
files |
Logical. If |
Registered datasets are better served by get_dataset(), which knows which
file to pick. This function has no such knowledge, so it lists the deposit
and applies the same format preference to whatever it finds. Deposits with an
unusual file layout may need filename or file_pattern to resolve, and
formats the package cannot read will raise an error naming the file.
DOIs under the 10.60873 and 10.48808 prefixes are served.
A tibble or sf object with the "doi" attribute
set. When files = TRUE, a character vector of filenames.
get_dataset() for registered datasets.
# Inspect a deposit before downloading get_dataverse("10.60873/FK2/YWXLQS", files = TRUE) # Paste a DOI straight from the Dataverse page linhas <- get_dataverse("10.60873/FK2/YWXLQS", filename = "dim_line.rds") # Or the landing-page URL linhas <- get_dataverse( paste0( "https://dataverse.datascience.insper.edu.br/dataset.xhtml?", "persistentId=doi:10.60873/FK2/YWXLQS" ), filename = "dim_line.rds" )# Inspect a deposit before downloading get_dataverse("10.60873/FK2/YWXLQS", files = TRUE) # Paste a DOI straight from the Dataverse page linhas <- get_dataverse("10.60873/FK2/YWXLQS", filename = "dim_line.rds") # Or the landing-page URL linhas <- get_dataverse( paste0( "https://dataverse.datascience.insper.edu.br/dataset.xhtml?", "persistentId=doi:10.60873/FK2/YWXLQS" ), filename = "dim_line.rds" )
Returns a tibble of datasets in the inspercidados registry.
list_datasets( search = NULL, theme = NULL, region = NULL, project = NULL, spatial = NULL, include = c("active", "catalogued", "all") )list_datasets( search = NULL, theme = NULL, region = NULL, project = NULL, spatial = NULL, include = c("active", "catalogued", "all") )
search |
A character string to filter results. Matched
case-insensitively against alias, title, description, keywords, theme, and
region. Pass |
theme, region, project
|
Optional filters, matched case-insensitively as regular expressions against the corresponding column. |
spatial |
Logical. If |
include |
Which registry entries to return. |
A tibble with one row per dataset and columns
alias, title, description, theme, region, project, access,
is_spatial, formats, keywords, and doi.
The registry is read from the package's GitHub repository once per
session, so datasets added after a release appear without reinstalling.
When GitHub cannot be reached, or the online registry needs a newer
version of the package, the copy shipped with the package is used instead.
Set options(inspercidados.registry = "bundled") to always use the
shipped copy, for example to keep a script's catalog fixed.
list_projects() for the studies these datasets come from.
# List all downloadable datasets list_datasets() # Search by keyword or theme list_datasets("metro") list_datasets("IPTU") # Only spatial datasets list_datasets(spatial = TRUE) # Datasets from one study list_datasets(project = "faixa_azul") # Include datasets that are catalogued but not downloadable list_datasets(include = "catalogued")# List all downloadable datasets list_datasets() # Search by keyword or theme list_datasets("metro") list_datasets("IPTU") # Only spatial datasets list_datasets(spatial = TRUE) # Datasets from one study list_datasets(project = "faixa_azul") # Include datasets that are catalogued but not downloadable list_datasets(include = "catalogued")
Most datasets come from a research project with its own processing pipeline. One project usually produces several datasets, and its pipeline is published as one repository.
list_projects(project = NULL)list_projects(project = NULL)
project |
Optional project slug or regular expression to filter on. |
A tibble with columns project, title,
repo_url, visibility, n_datasets, and datasets. repo_url is NA
for projects whose code has not been published yet, and visibility is
"private" for repositories that only Insper Cidades members can open.
open_project() to open a repository, list_datasets() for the
datasets themselves.
list_projects() list_projects("motiva")list_projects() list_projects("motiva")
Returns the logical resources registered within a dataset. A resource is one
dataset that may be distributed in several file formats or split by a
declared dimension such as year. The information comes from the registry
(see list_datasets()), so Dataverse is not queried.
list_resources(dataset)list_resources(dataset)
dataset |
A registered dataset alias. See |
A tibble with one row per resource and columns
resource, title, is_spatial, years, formats, and default.
get_dataset() to download a resource.
list_resources("qualidade_ar_mare") list_resources("pemob_anual")list_resources("qualidade_ar_mare") list_resources("pemob_anual")
Prints the study a dataset came from, the other datasets it produced, and the repository holding its processing code, then opens that repository in a browser.
open_project(x, open = TRUE)open_project(x, open = TRUE)
x |
A dataset alias (see |
open |
Logical. If |
One study normally produces several datasets, and its pipeline is published
as one repository. Some repositories are private and open only for Insper
Cidades members; list_projects() reports which.
The repository URL, invisibly, or NULL when no repository is
registered for the project.
# By dataset alias open_project("sinistros_sp", open = FALSE) # By project slug open_project("motiva", open = FALSE)# By dataset alias open_project("sinistros_sp", open = FALSE) # By project slug open_project("motiva", open = FALSE)
Opens a registered parquet dataset as a lazy table backed by DuckDB.
DuckDB reads the file directly from Insper Dataverse and fetches only the
columns and row groups a query needs, so large datasets such as
"itbi_sp" can be filtered and summarised without loading them into
memory. Use dplyr verbs to build the query and dplyr::collect() to bring
the result into R.
query_dataset(dataset, ..., resource = NULL, year = NULL)query_dataset(dataset, ..., resource = NULL, year = NULL)
dataset |
A registered dataset alias, e.g. |
... |
Must be empty. Arguments after |
resource |
The name of a logical resource within the registered
dataset. When |
year |
An integer or character year used to keep a single annual file.
When |
Only resources distributed as parquet can be queried; use get_dataset()
for the others. When a resource is split into annual files and year is
NULL, all years are combined into one table.
DuckDB loads httpfs from its shared extension cache or installs it on the
first call. The cache is stored under ~/.duckdb.
A lazy dbplyr table (tbl_duckdb_connection)
with the "doi" attribute set.
get_dataset() to download a dataset into memory.
itbi <- query_dataset("itbi_sp") # Transactions per year, computed by DuckDB itbi |> dplyr::count(ano = dplyr::sql("year(data_de_transacao)")) |> dplyr::arrange(ano) |> dplyr::collect()itbi <- query_dataset("itbi_sp") # Transactions per year, computed by DuckDB itbi |> dplyr::count(ano = dplyr::sql("year(data_de_transacao)")) |> dplyr::arrange(ano) |> dplyr::collect()