Interactive Car Data Visualization

This presentation explores fuel economy and vehicle characteristics using the built-in mtcars dataset.

MPG by Transmission

library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
data(mtcars)

mtcars$Transmission <- factor(
  mtcars$am,
  levels = c(0, 1),
  labels = c("Automatic", "Manual")
)

plot_ly(
  data = mtcars,
  x = ~Transmission,
  y = ~mpg,
  type = "box",
  color = ~Transmission,
  text = ~paste(
    "Car:", rownames(mtcars),
    "<br>MPG:", mpg,
    "<br>Weight:", wt
  ),
  hoverinfo = "text"
) %>%
  layout(
    title = "Fuel Economy by Transmission Type",
    xaxis = list(title = "Transmission"),
    yaxis = list(title = "Miles per Gallon (MPG)")
  )
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels

Conclusion

Compare the distributions of MPG for automatic and manual transmissions. Hover over the plot to explore individual observations.