Motor Trend Car Road Tests

Description

This dataset, extracted from the 1974 Motor Trend US magazine, includes fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models).

Variable Types

In this dataset, variables are categorized as either categorical or quantitative:

  • Categorical Variables:
    • cyl (Number of cylinders)
    • vs (Engine: 0 = V-shaped, 1 = straight)
    • am (Transmission type: 0 = automatic, 1 = manual)
    • gear (Number of forward gears)
    • carb (Number of carburetors)
  • Quantitative Variables:
    • mpg (Miles per gallon)
    • disp (Displacement in cubic inches)
    • hp (Gross horsepower)
    • drat (Rear axle ratio)
    • wt (Weight in 1000 lbs)
    • qsec (1/4 mile time)

The following sections demonstrate different ways to visualize data distributions and relationships between variables.

Data Table

##                    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

Visualizations

Distribution of a Categorical Variable: Cylinders

A bar chart is a useful way to show the frequency of each category in a categorical variable, such as the number of cylinders (cyl) in this dataset. Each bar represents the count of cars for a given cylinder count.

Bar Chart of Cylinders

A pie chart is another way to represent the relative proportions of each category. Here, we can see the distribution of cars based on their cylinder counts as slices of a pie.

Pie Chart of Cylinders

Distribution of a Quantitative Variable: Miles Per Gallon (MPG)

To understand the distribution of a quantitative variable like mpg, we use the following plots:

This shows how frequently different ranges of MPG values appear.Each bar represents a range of values, providing insight into the spread and shape of the data.

Histogram of MPG

  • Stemplot: A stem-and-leaf plot represents individual values and is helpful for smaller datasets. Each “leaf” represents an observation, making it easy to see exact values.

Stemplot of MPG

## Stemplot of MPG:
## 
##   The decimal point is at the |
## 
##   10 | 44
##   12 | 3
##   14 | 3702258
##   16 | 438
##   18 | 17227
##   20 | 00445
##   22 | 88
##   24 | 4
##   26 | 03
##   28 | 
##   30 | 44
##   32 | 49
  • Dotplot: A dot plot visualizes each data point as a dot along a scale, showing individual observations and overall distribution.

  • Boxplot: A boxplot provides a summary of the distribution, highlighting the median, quartiles, and potential outliers. It’s useful for comparing distributions or spotting outliers.

Boxplot of MPG

  • Line Graph: A line graph connects data points in sequence, which is helpful to see any trends or fluctuations over an ordered index.

Line Graph of MPG

Relationship Between Two Categorical Variables: Cylinders and Transmission

To explore the relationship between two categorical variables, cyl and am, we can use side-by-side and stacked bar charts. These show how each transmission type is distributed across different cylinder counts.

Side-by-Side Bar Graph of Cylinders vs. Transmission

  • Stacked Bar Graph: This bar graph stacks counts within each cylinder category, making it easy to see the total count as well as the breakdown by transmission type.

Stacked Bar Graph of Cylinders vs. Transmission

  • Contingency Table: This table summarizes the counts of each combination of cyl and am.
##    
##     Automatic Manual
##   4         3      8
##   6         4      3
##   8        12      2

Relationship Between Two Quantitative Variables: Horsepower (HP) and MPG

A scatterplot is ideal for visualizing the relationship between two quantitative variables, such as hp (horsepower) and mpg. Each point represents a car, with its hp on the x-axis and mpg on the y-axis, helping us see if there’s any trend.

Scatterplot of HP vs MPG

Adding a trend line to the scatterplot helps visualize any linear relationship between hp and mpg. Here, we add a regression line to see how mpg changes as hp increases.

HP vs MPG with Trend Line

Categprical vs. Quantitative Variables

  • Side-by-Side boxplot:

  • Dotplot with jitter