# Introduction to flightsbr

flightsbr is an R package to download flight and airport data from Brazil’s Civil Aviation Agency (ANAC). The package currently includes four main functions:

1. `read_flights()`
2. `read_airports()`
3. `read_aircrafts()`
4. `read_airport_movements()`

### 1) `read_flights()`:

Flights data include detailed information on every international flight to and from Brazil, as well as domestic flights within the country. The data include flight-level information of airports of origin and destination, flight duration, aircraft type, payload, and the number of passengers, and several other variables. - Data dictionary for flights.

### 2) `read_airports()`

Airports data covers all airports and aerodromes registered in Brazil’s Civil Aviation Agency (ANAC). It covers detailed information on ICAO code, municipality, geographical coordinates, runway dimensions etc.

- Data dictionary:
  - Public airports.
  - Private airports.

### 3) `read_aircrafts()`:

All aircrafts registered in the Brazilian Aeronautical Registry (Registro Aeronáutico Brasileiro - RAB), organized by the Brazilian Civil Aviation Agency (ANAC). - Data dictionary for aircrafts data.

### 4) `read_airport_movements()`:

The data covers all passenger, aircraft, cargo and mail movement from airports regulated by ANAC. - Data dictionary for airport movements data.

## Basic usage

Before using flightsbr please make sure that you have it installed on your computer. You can download the most stable version from CRAN.

    install.packages("flightsbr")

Now we can load the library and start downloading data.

    library(flightsbr)

#### Download flights data:

    # in a given **month* of a given **year** (yyyymm)
    df_201506 <- read_flights(date=201506, showProgress = FALSE)

    # in a given year (yyyy)
    df_2015 <- read_flights(date=2015, showProgress = FALSE)

#### Download airports data:

    airports_all <- flightsbr::read_airports(type = 'all', showProgress = FALSE)

    airports_prv <- flightsbr::read_airports(type = 'private', showProgress = FALSE)

    airports_pbl <- flightsbr::read_airports(type = 'public', showProgress = FALSE)

#### Download data of aircrafts:

    aircrafts <- flightsbr::read_aircrafts(showProgress = FALSE)

    head(aircrafts)

#### Download data on airport movements:

    airport_mov <- flightsbr::read_airport_movements(date=201901)

    head(airport_mov)