5.1. Exercises
Melting Questions
Applying Melt
Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.
When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.
Let’s take a look at some new untidy data that we have named lego.
Let’s melt this so that the 2 new columns named matte and transparent become a single one. These columns refer to the opacity of the blocks and the values refer to the number of pieces of each included in the set. Since our variable of interest in this scenario is opacity, we need to combine the two measurements into one column.
Tasks:
meltthe dataframe columnsmatteandtransparentinto a single column namedopacityand name the values columnquantity.- Name the new dataframe
tidied_lego.