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
price
andcut
highest
price
andcut
Arrange the diamonds by lowest to highest
price
and worst to bestclarity
.Create a new variable named
salePrice
to reflect a discount of $250 off of the original cost of each diamond (hint:mutate()
).Remove the
x
,y
, andz
variables from thediamonds
dataset (hint:select()
).Determine the number of diamonds there are for each
cut
value (hint:group_by()
,summarize()
).Create a new column named
totalNum
that calculates the total number of diamonds.