Developing Data Products Assignment 3: R Markdown Presentation and Plotly

ITguy666

2026-07-12

Overview

This presentation features an interactive plot created with Plotly as part of the Week 3 Peer-Graded Assignment for the Developing Data Products Coursera course.

The data analysed is from the classic mtcars dataset, visualizing the relationship between a car’s weight and its miles per gallon (MPG).

We first load the library for plotly and ggplot2.

library(plotly)
library(ggplot2)

Interactive Plot

For the chart, you may hover over the data points to view specific vehicle specs. You can also zoom in on specific regions or use the legend to filter by the number of cylinders.

# Create the interactive plot
plot_ly(data = mtcars, x = ~wt, y = ~mpg, color = ~factor(cyl), type = "scatter", 
  mode = "markers", text = ~paste("Car:", rownames(mtcars))) %>%
  layout( title = "Motor Trend Car Road Tests", xaxis = list(title = "Weight (1000 lbs)"),
    yaxis = list(title = "Miles Per Gallon (MPG)"), legend = list(title = list(text = "Cylinders")))