Worksheet 99

Published

November 2, 2024

Opening blurb here.

Packages

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Motor Trend cars

In 1974, the Motor Trend magazine collected data on fuel consumption and other features of 32 different makes of car. The data are available in the built-in dataset mtcars. The variables of interest to us are:

  • mpg: fuel consumption in miles per US gallon
  • cyl: number of cylinders in the engine
  • wt: weight of car, in thousands of pounds.
  1. Make a suitable plot of fuel consumption against weight.
  1. Modify your plot to distinguish cars with different numbers of cylinders by colour.

Making soap

A factory makes soap. There are two production lines, a and b. These can be run at different speeds; running the production line faster produces more soap, but it also produces more scrap (soap that cannot be sold). Does the amount of scrap differ by production line? Answer the questions below to find out. The data is in https://ritsokiguess.site/datafiles/soap.txt.

  1. Read in and display some of the data.
  1. Make a suitable plot of the scrap produced and the production line. How do the production lines compare?
  1. Do you get a different story if you include speed in your plot?