Skip to contents

Reads and combines one or more Infosiga data files (CSV) of a specific type from a given directory into a single data frame.

Usage

load_infosiga(file_type = c("sinistros", "pessoas", "veiculos"), path)

Arguments

file_type

A string specifying the type of data to load. Must be one of 'sinistros' (the default), 'pessoas', or 'veiculos'.

path

A string specifying the path to the directory containing the Infosiga CSV files.

Value

A tibble (data frame) containing the combined data from all matching CSV files.

Details

This function searches for all files in the specified path that start with the file_type prefix (e.g., sinistros_2023.csv). It then uses readr::read_csv2 to parse these semicolon-separated files. The function assumes 'latin1' encoding, which is necessary for handling special characters in the original data. All found files of the same type are stacked into a single tibble.

Examples

if (FALSE) { # \dontrun{
# First, download the data
data_dir <- tempdir()
download_infosiga(destpath = data_dir)

# Now, load the 'sinistros' data
df_sinistros <- load_infosiga(file_type = "sinistros", path = data_dir)

# Load the 'pessoas' data
df_pessoas <- load_infosiga(file_type = "pessoas", path = data_dir)
} # }