If a golf ball and a club together cost 2,100 PLN, and the price difference between the club and the ball is 2,000 PLN, then how much costs the ball?
Consider the data-frame mtcars
(it should be loaded when you load R, if not, it is provided by the library datasets
). Calculate
Then create a function to convert miles per gallon to liter per 100 km, rounded up to 2 digits. Then add a column lp100km
where you put all the consumption in liter per 100 km and store the results in a variable d
Now execute the same with a for-loop.
Create a function to demonstrate the lexical scoping in R
Create an object type cardata
, that is your personal soution for car databases. create a specific print function that plots mpg
in function of hp
when called by plot(x)
Consider the dataset mtcars
and sumarise the fuel consumption in function of the number of cylinders.
## ── 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
Now for both cyl and vs
## `summarise()` has grouped output by 'dispCats'. You can override using the `.groups` argument.
## `summarise()` has grouped output by 'dispCats'. You can override using the `.groups` argument.
Create a dataset d
as a copy of mtcars
with one column extra for the fuel consumption in SI.
Plot the mpg in function of all other variables for mtcars
.
Plot the fuel consumption in function of the horse power of the motor with blue crosses
use the data of the Standards and Poors index, it is in R as SP500
, convert it to a time series with start date january 1990, and produce moving average forecast.