<- c(2.6822919, 1.8485851, 1.0039014, 1.9612068, 0.5475432) my_numbers
Skills Lab 03: Logic of piping |>
Google doc: https://bit.ly/skills-lab-03
Functions and arguments
Task 1
- Run the chunk below to create and object called
my_numbers
- Look up the help documentation for the
round()
function - Round
my_numbers
to 2 decimal places.
Using the pipe
Task 2
- Round
my numbers
to 2 decimal places by pipingmy_numbers
into theround()
function. - Round
my numbers
to 2 decimal places by piping number2
into theround(
) function.
|> round(????) my_numbers
2 |> round(????)
Connecting functions with a pipe
Task 3
- Run the code below to read in
spotify_data.
- Without using the pipe change the dataset so that:
- It only contains rows with tracks in the F Major key
- It only contains columns with track name, artists name, and year of release
- Save the amended dataset into an object called
spotify_edited
using the assignment operator
<- readr::read_csv("data/tutorial_03_data.csv") spotify_data
Task 4
Change the code from the previous task into a pipeline.
Task 5
Using the pipe, complete the following tasks.
- Amend the
spotify_data
so that:- It only contains columns with track name, release year, and number of spotify charts
- Create a new column in
spotify_data
calledscore
.score
can be computed by diving the number of spotify charts by the number of playlists. - Save this new version of the dataset into an object called
spotify_new
- It only contains columns with track name, release year, and number of spotify charts