The chunk below runs two commands: 1) Loads “readr” package into the User Library, and 2) Loads the Excel file “cars_data.csv” to the Environment as an object named “cars_data”.
library(readr)
cars_data <- read_csv("cars_data.csv")
## New names:
## Rows: 32 Columns: 12
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): ...1 dbl (11): mpg, cyl, disp, hp, drat, wt, qsec, vs, am, gear, carb
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
This chunk runs 3 commands: 1) The average (mean) mpg for all cars, 2) The minimum mpg for all cars, and 3) The maximum mpg for all cars.
mean(cars_data$mpg)
## [1] 20.09062
min(cars_data$mpg)
## [1] 10.4
max(cars_data$mpg)
## [1] 33.9
The chunk below runs a command to find the number of observations (cars) in the dataset:
length(cars_data$mpg)
## [1] 32