The Art of Data

An Exploration of Automobiles

Published

today


DATA JOURNAL · NO. 001

Finding stories in numbers

A small study of cars, performance, and the relationship between weight and fuel efficiency.

This project explores the mtcars dataset using R, combining statistical summaries and visualizations in one reproducible report.

At a glance

Sample size
32
Automobile models
Average MPG
20.1
Miles per gallon
Average HP
146.7
Horsepower

01 — Getting to know the data

The mtcars dataset is built into R. It contains information about 32 automobiles, including fuel consumption, engine power, and vehicle weight.

head(mtcars, 6)
                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1

A note on the data

MPG stands for miles per gallon. Higher values indicate better fuel efficiency. Vehicle weight is measured in thousands of pounds.

02 — The numbers behind the story

The following table summarizes several useful measurements.

data.frame(
  Measure = c(
    "Number of automobiles",
    "Average fuel efficiency",
    "Average horsepower",
    "Average vehicle weight"
  ),
  Value = c(
    nrow(cars),
    paste(avg_mpg, "MPG"),
    avg_hp,
    paste(avg_wt, "thousand lbs")
  )
)
                  Measure             Value
1   Number of automobiles                32
2 Average fuel efficiency          20.1 MPG
3      Average horsepower             146.7
4  Average vehicle weight 3.22 thousand lbs

03 — Visual exploration

Weight and fuel efficiency

Heavier cars tend to achieve fewer miles per gallon. The scatter plot shows this relationship across the vehicles in the dataset.

par(
  mar = c(4.5, 4.5, 2.5, 1),
  family = "sans",
  col.axis = "#788176",
  col.lab = "#24392E"
)

plot(
  cars$wt, cars$mpg,
  pch = 21,
  bg = "#A9BCA0",
  col = "#405C45",
  lwd = 1.2,
  cex = 1.35,
  xlab = "Vehicle weight (1,000 lbs)",
  ylab = "Fuel efficiency (MPG)",
  main = "Weight vs. fuel efficiency",
  bty = "l",
  las = 1
)

abline(
  lm(mpg ~ wt, data = cars),
  col = "#C47E61",
  lwd = 2.5
)

Vehicle weight and fuel efficiency. The line represents a fitted linear trend.

A closer look at horsepower

Horsepower varies substantially between automobile models. The histogram helps show how the values are distributed.

par(
  mar = c(4.5, 4.5, 2.5, 1),
  col.axis = "#788176",
  col.lab = "#24392E"
)

hist(
  cars$hp,
  breaks = 8,
  col = "#A9BCA0",
  border = "#F8F7F2",
  main = "Horsepower distribution",
  xlab = "Horsepower",
  ylab = "Number of cars",
  bty = "l",
  las = 1
)

Distribution of horsepower across 32 automobiles.

04 — What we learned

  • 32 automobiles are included in the dataset.
  • Average fuel efficiency is approximately 20.1 MPG.
  • Average horsepower is approximately 146.7.
  • The data shows a negative relationship between vehicle weight and fuel efficiency.

Final thoughts

Data analysis is more than calculating numbers. It is about finding patterns, asking meaningful questions, and communicating results clearly.

This project demonstrates how R and Quarto can bring together code, tables, and visualizations in a single, reproducible document.