Major changes:
tools::R_user_dir("flightsbr", which = "cache"), so they
persist across R sessions and each file is downloaded only once. A
cached file is downloaded again only if ANAC’s copy has a different
size, or when cache = FALSE. If ANAC can’t be reached to
check, the cached file is used. Closes #49.set_flightsbr_cache_dir() sets the cache folder (the
choice is kept across R sessions),get_flightsbr_cache_dir() returns path to cache
dirlist_flightsbr_cache() lists the cached filesdelete_flightsbr_cache() deletes some or all of the
cached files.Minor changes:
showProgress = FALSE now hides all of them, and {pbapply}
is no longer a dependency.Breaking changes:
read_airfares() now returns the same column names for
every period, using the names of ANAC’s current files:
nr_ano_referencia, nr_mes_referencia,
sg_empresa_icao, sg_icao_origem,
sg_icao_destino, nr_tarifa,
nr_assentos, and for international flights also
sg_icao_retorno, cd_classe_ida and
cd_classe_volta. Older names such as ano,
tarifa or valor_tarifa are no longer returned,
but are still accepted by select.nr_voo and nr_chave
(read_flights()), nr_voo_numero
(read_airport_movements()), and nr_serie and
nr_cert_matricula (read_aircraft()).nr_*,
qt_*, …) is converted to numeric only if all its values are
numbers. Otherwise it stays character, with a message when only a few
values are the problem (e.g. nr_preco_venda in recent RAB
files). The type of such a column can therefore differ between requests
for different months.read_aircraft(): the registration “marca” column is
always called marcas (it was marca in files
before 2026), and empty cells and the text "null" are
returned as NA.Bug fixes:
read_airport_movements() returning
NA for every airport, airline and aircraft code: the codes
in nr_* columns were converted to numbers.read_aircraft() returning NA for
many serial numbers and almost all sale prices, which use Brazilian
number formatting ("1.500.000,00").cache = TRUE. Files are now downloaded to a
temporary file and only kept when the download succeeded and is not a
web page. Downloads are retried and run at most four at a time.read_airfares() splitting fares and other columns
into separate, half-empty columns when the requested months use
different ANAC headers. Files with an unknown header now fail with an
error.read_airfares() failing for months that ANAC
re-uploaded under another name (e.g. May 2026,
202605 (1).csv). Download links now come from ANAC’s
listing.read_aircraft(),
read_airport_movements() and read_airfares()
with a year (date = yyyy) failing whenever any month of
that year is not available on ANAC. They now read the available months
and list the missing ones in a message.read_airports() returning NA
coordinates for about 29% of private airports (seconds written with a
decimal comma), and altitude 0 for airports whose altitude
is missing (",0"). latgeopoint and
longeopoint are now numeric.proprietarios, operadores) not being valid
JSON. read_aircraft() warns when the requested months use
different RAB layouts.read_flights() for the rest of the
session. latest_flights_date() returns NULL
instead of -Inf when ANAC can’t be reached.read_airfares() rejects domestic = NA and
vectors of length > 1.data.table.read_flights() failing to download any data.
ANAC’s website now lists flight files with relative links that lead to
an HTML page instead of the zip file. The package now builds the direct
download link
(https://www.gov.br/.../<file>.zip/@@download/file),
saves each month under its own file name, and checks that each
downloaded file is really a zip archive, with a clear message when ANAC
returns a web page instead.Minor changes:
read_aircrafts() now throws an error, as
it has been deprecated in favor of read_aircraft() simply
to fix a typo in the function name. The behavior and outputs are
identical.read_airfares() and read_flights() now
cache the list of dates/files available from ANAC to a session-scoped
temp file, governed by the existing cache parameter. This
avoids re-scraping ANAC’s website on every single call within the same R
session.httr2::req_perform_parallel(), replacing
curl::multi_download().Bug fixes:
select parameter in
read_airfares(), which was silently ignored and had no
effect on the columns returned. It now behaves the same way as
select in read_flights().get_airfares_dates_available() (used internally
by read_airfares()) to retry requests to ANAC that fail
transiently (timeouts, connection errors, HTTP 429/503) instead of
silently dropping the affected year and returning an incomplete list of
available dates.get_airfares_dates_available() and
latest_airfares_date() to fail cleanly with
NULL when ANAC can’t be reached, instead of occasionally
producing a nonsensical “data available between Inf and -Inf” error, or
-Inf as a date.nchar == 55) used to filter valid international airfare
files listed by ANAC with an explicit filename-pattern check, and added
the equivalent check to the domestic airfare listing (which previously
had no filter at all). This guards against malformed, duplicate, or
misplaced files that ANAC occasionally publishes (e.g. typo’d names,
files uploaded to the wrong year, re-uploads with (1)
appended) corrupting the list of available dates.New contributors
read_ functions now is to download
data from the latest date available.read_aircrafts() is now deprecated in
favor of read_aircraft() simply to fix a typo in the
function name. The behavior and outputs are identical. Closes #45read_airports() now downloads v2 version of
public airports data. Closes #41yyyymm OR a
4-digit format yyyy.latest_airfares_date()read_aircraft() for multiple months when the number of
collums differed across months. Fixed using
data.table::rbindlist(fill = TRUE)read_flights(),
read_airport_movements(), and read_aircraft()
now accept vectors of dates like c(202201, 202301) or
c(2022, 2024)read_airports() and
read_aircraft() now has a cache
parameter.curl::multi_download() to download files in parallel. This
brings the advantage that the package now automatically detects whether
the data file has been updated and should be downloaded again.read_flights() function now uses
fread(encoding = 'Latin-1') internally to avoid issues with
encoding. Closed #35.get_airport_movement_dates_available()
does not throw warnings of NA values anymore.read_aircraft() function now used
fread(skip = 1) internally to read column names
correctly.read_flights() and
read_airport_movements() now have a new parameter
cache, which indicates whether the function should read
cached data downloaded previously. Defaults to TRUE. Closed
#31.read_aircraft() now has a
date parameter, which allows one to download the data on
aircraft registered at ANAC at particular years/months. Closed #33.numeric
class. Closed #32.read_flights()
function in Unix systems. Closed #31.read_flights() now accepts a vector of dates.
Closed #29.get_airfares_dates_available() because of “.CSV” in ANAC
url. Closed #27.get_airport_movement_dates_available()read_flights() due to changes in ANAC data
links.intro_flightsbr vignetteread_flights() work again.read_airfares() to read data on airfares
of domestic and international flights Closed #22.read_flights() and
read_airport_movements() no longer have side effects on
objects named month and year on the global
environment. The split_date() support function was removed
from the package. Closed #17.read_ functions now try to download for a 2nd time if
the 1st attempt failed. This will help overcome a small issue with the
instability of ANAC data links. Closed #18.latlon_to_numeric() with suppressed warnings.read_aircraft() to read data on all
aircraft registered in the Brazilian Aeronautical Registry (Registro
Aeronáutico Brasileiro - RAB) Closed #14.read_airports() to read data on all public
and private airports. Closed #4 and Closed #9.latest_flights_date() to check the date of
the latest flight data available. Closed #16.read_airport_movements() to download data
on airport movements. Closed #15.read_flights() now takes date
input in the format yyyymm or yyyy. When the
date input is a 4-digit number, the function now downloads data of all
months in that year. Closed #1.read_flights() now automatically detects and
checks the latest flights data available. Closed #13.split_date(): Split a date from yyyymmm to year yyyy
and month mmcheck_date(): Check whether date input is
acceptablegenerate_all_months(): Generate all months with
yyyymm format in a yearlatlon_to_numeric(): Convert spatial coordinates of
airports to lat longet_flights_url(): Put together the url of flight data
filesget_flight_dates_available(): Retrieve from ANAC
website all dates available for flights datadownload_flights_data(): Download and read ANAC flight
dataget_airport_movements_url(): Put together the url of
airport movement data filesget_airport_movement_dates_available(): Retrieve all
dates available for airport movements datadownload_airport_movement_data(): Download and read
ANAC airport movement dataread_flights and
read_airports().