6.7 Extra Practice
Keep practicing these functions! The more you practice, the better you’ll be when it comes time to manage your own code!
Using the diamonds built-in dataset (requires tidyverse), perform the following tasks:
View all of the variable names in
diamonds(hint:View()).Arrange the diamonds by:
Lowest to highest
price(hint:arrange())Highest to lowest
price(hint:arrange(),desc())Lowest
priceandcuthighest
priceandcut
Arrange the diamonds by lowest to highest
priceand worst to bestclarity.Create a new variable named
salePriceto reflect a discount of $250 off of the original cost of each diamond (hint:mutate()).Remove the
x,y, andzvariables from thediamondsdataset (hint:select()).Determine the number of diamonds there are for each
cutvalue (hint:group_by(),summarize()).Create a new column named
totalNumthat calculates the total number of diamonds.