Start from mtcars
and
Create a new column for the brand
Create a new column for the make
Create a field “code” that holds the code hp/wt/mpg
## ── Attaching core tidyverse packages ────────────────────────────────────────────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── 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
## Warning: Expected 3 pieces. Missing pieces filled with `NA` in 27 rows [1, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
## 18, 19, 20, 21, 22, ...].
Display the name and brand as well as mpg for all cars that have a mpg between 15 and 20
Create a new column “ltr” that contains the fuel consumption in liters per hundred kilometers
Add a column “nice” that contains “:-)” if the mpg is below 15 and the hp is above 100, and “:-(” otherwise.
Start again from mtcars and extract brand and make via regex
Try the same by using the library rex
##
## Attaching package: 'rex'
## The following object is masked from 'package:stringr':
##
## regex
## The following object is masked from 'package:dplyr':
##
## matches
## The following object is masked from 'package:tidyr':
##
## matches
Consider a moment in the past (e.g. your start-date at HSBC, your birth-date, N. Armstrong steps on the moon, etc)
Use the dataset mtcars
and
am)
,A
for automatic and M
for manual,Consider mtcars
and define a variable is_economical
that is based on mpg
with a 1
where mpg is above \(20 mpg\) and a 0
elsewhere.
Assume that we prepare a logistic regression to explain is_economical
. Find a good binning for the number of carburetors (the variable carb)
.