knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  dpi = 300,
  message=FALSE,
  warning=FALSE
)

Travis build status AppVeyor build status CRAN_Release_Badge CRAN_Download_Badge

fipe

fipe is a R package to access Fipe’s average purchase price of vehicles in the Brazilian national market. The prices are effectively used in purchase negotiations according to region, vehicle’s conservation, color, accessories or any other factor that might influence the demand and supply for a specific vehicle. The year of the vehicle refers to the model year, and the vehicles are not considered for professional or special use. The values are expressed in R$ (reais) for each month/year of reference.

Installation

You can install the development version from github:

# install.packages('devtools')
devtools::install_github('italocegatta/fipe')

The stable version is availabe on CRAN

install.packages("fipe")

Example

The function fipe_vehicle provide access to historical data of brazilian cars price

library(fipe)
library(ggplot2)
library(dplyr)

bmw_x6  <- fipe_vehicle(
  model = "x6 ", 
  make = "bmw", 
  year = c(0, 2017:2015),
  date = seq.Date(as.Date("2013-01-01"), as.Date("2017-12-01"), by = "4 months")
)

bmw_x6 
bmw_x6 %>%
  ggplot(aes(date, price, color = year, group = year)) +
    geom_line(color = "grey30") +
    geom_point(size = 3) +
    facet_wrap(~model) +
    labs(
      x = "Referance date",
      y = "Price (R$)",
      color = "Year"
    ) +
    scale_y_continuous(breaks = seq(0, 700000, 50000), labels = scales::number) +
    scale_x_date(date_breaks = "1 year", date_labels = "%b/%y") +
    scale_color_viridis_d() +
    theme_bw() +
    theme(legend.position = "top") 
bmw_x6 %>% 
  filter(date == max(date)) %>% 
  mutate(model = reorder(model, price, max)) %>% 
    ggplot(aes(price, model)) +
    geom_line(aes(group = model), color = "cadetblue4", size = 2) +
    geom_point(size = 10, color = "cadetblue4") +
    geom_text(aes(label = year), color = "white", size = 3) +
    labs(
      x = "Price (R$)",
      y = "Model"
    ) +
    scale_x_continuous(breaks = seq(0, 700000, 50000), labels = scales::number) +
    theme_bw()


italocegatta/fipe documentation built on Sept. 3, 2019, 2:17 p.m.