my_numbers <- c(2.6822919, 1.8485851, 1.0039014, 1.9612068, 0.5475432)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_numbersto 2 decimal places.
Using the pipe
Task 2
- Round
my numbersto 2 decimal places by pipingmy_numbersinto theround()function. - Round
my numbersto 2 decimal places by piping number2into theround() function.
my_numbers |> round(????)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_editedusing the assignment operator
spotify_data <- readr::read_csv("data/tutorial_03_data.csv")Task 4
Change the code from the previous task into a pipeline.
Task 5
Using the pipe, complete the following tasks.
- Amend the
spotify_dataso that:- It only contains columns with track name, release year, and number of spotify charts
- Create a new column in
spotify_datacalledscore.scorecan 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