library(tidyquintro)
library(learnr)
library(gradethis)

knitr::opts_chunk$set(echo = FALSE,
                 exercise.warn_invisible = FALSE)

# enable code checking
tutorial_options(exercise.checker = grade_learnr)

Piping the commands

Alter the code so that instead of being a standard R command, that the data is piped into the command instead.

filter(penguins, species == "Gentoo")
penguins |> filter(species == "Gentoo")
grade_code(
  correct = random_praise(),
  incorrect = random_encouragement()
)
enter the dataset first then pipe ` |> ` into the filter function, excluding the data set name inside the filter

Chain the commands

Alter the code below so that rather than being two distinct function calls, they are piped into each other.

Alter the code so that instead of being a standard R command, that the data is piped into the command instead.

penguins |> 
  filter(species == "Gentoo")

penguins |> 
  select(species, contains("bill"))
penguins |> 
  filter(species == "Gentoo") |> 
  select(species, contains("bill"))
grade_code(
  correct = random_praise(),
  incorrect = random_encouragement()
)


Athanasiamo/tidyquintro documentation built on Oct. 11, 2022, 7:15 p.m.