This page contains several tests. The output of each answer is shown in order to help you understand the questions. The code itself is hidden and you can unfold them when needed. It is recommended that you go through the basic before taking the following exercises.
Use the original tbl, create a new column “Kg” and assume that the weight columns is in tons that you convert to Kg. Afterwards, delete the weight column. Keep only values smaller than 5000 Kg. Sort the data so that the largest Kg are on top
path <-"https://raw.githubusercontent.com/SchmidtPaul/dsfair_quarto/master/data/Mead1993.csv"dat <-read_csv(path, col_types =cols()) # use path from above
---title: "Exercise of `{tidyverse}`"code-fold: true---## IntroductionThis page contains several tests. The output of each answer is shown in order to help you understand the questions. The code itself is hidden and you can unfold them when needed. It is recommended that you go through [the basic](playing-with-data.html) before taking the following exercises.```{r load packages & data}#| output: false#| echo: false# (install &) load packagespacman::p_load( broom, conflicted, modelbased, tidyverse)# handle function conflictsconflicts_prefer(dplyr::filter)conflicts_prefer(dplyr::select)```## Exercise 1Given the data:```{r load_tibble}#| code-fold: falsetbl <- as_tibble(PlantGrowth)tbl```Use the original `tbl`, create a new column "Kg" and assume that the weight columns is in tons that you convert to Kg.Afterwards, delete the weight column.Keep only values smaller than 5000 Kg.Sort the data so that the largest Kg are on top```{r}tbl %>%mutate(Kg = weight *1000) %>%select(-weight) %>%filter(Kg <5000) %>%arrange(desc(Kg))```## Exercise 2Given the data `dat`:```{r}#| code-fold: false#| output: falsepath <-"https://raw.githubusercontent.com/SchmidtPaul/dsfair_quarto/master/data/Mead1993.csv"dat <-read_csv(path, col_types =cols()) # use path from above``````{r}#| code-fold: falsedat```Find out the average, minimum and maximum yields per variety using `summarise()`. Arrage as the highest value on the top.```{r}dat %>%group_by(variety) %>%summarise(avg_yield =mean(yield),min_yield =min(yield),max_yield =max(yield) ) %>%arrange(desc(avg_yield))```