Challenges Set 3

Instructions

Use the starwars dataset from the dplyr package (loaded already with tidyverse) to complete the below challenges. I highly recommend all of you to first get to know the starwars dataset by trying the “Get to know your data” functions covered at the beginning of the Week 2 Starter file. Good luck and have fun in completing them:

Important

You must use the pipe (|>) to successfully complete the below challenges

Challenge 1:

Use the starwars dataset and apply the following manipulations at the same time using pipes. Do not create any intermediate objects (one big chunk of code):

  1. Keep the columns nameheightmassspecies, and homeworld.

  2. Sort the data from the tallest to the shortest height.

  3. Create a new column height_m equal to height / 100.

  4. Remove characters with height_m < 1.

  5. Group by species, and compute the average, minimum, maximum, standard deviation, and median of height_m. Moreover, produce a count of characters in each species.

Challenge 2:

Use the starwars dataset and apply the following manipulations at the same time using pipes. Do not create any intermediate objects (one big chunk of code):

  1. Create a column bmi equal to mass / (height / 100)^2.

  2. Select the columns namespeciesbmi, and homeworld.

  3. Keep in the dataset only the characters that are “droids”.

  4. For each homeworld:

    • Compute the average and standard deviation of bmi.

    • Produce a count of available characters

  5. Reorder the dataset from the highest to the smallest average bmi.

Challenge 3:

Use the starwars dataset and apply the following manipulations at the same time using pipes. Do not create any intermediate objects (one big chunk of code):

  1. Reorder the data from the largest to the smallest year of birth.

  2. Keep only the columns hair_coloreye_colorbirth_year, and homeworld.

  3. Remove characters with missing hair_color and missing birth_year

  4. Per each eye_color, compute the average, minimum, maximum, standard deviation, and median of birth_year.

  5. Compute a column range_birth_year equal to maximum - minimum of birth_year.

Challenge 4:

Use the starwars dataset and apply the following manipulations at the same time using pipes. Do not create any intermediate objects (one big chunk of code):

  1. Keep the columns homeworldspecies, and mass.

  2. Per each homeworld calculate the total mass of all characters.

  3. Keep only the homeworld where the total mass of characters is above 100.

  4. Sort the dataset by total mass in descending order.

  5. Show the top 5 heaviest homeworld by total character mass. [Hint: you might need to get creative with this one]

🛑 Don’t Click Submit Just Yet 🚧

Please read carefully the below information:

  • Once you have completed all the coding challenges, and your confident in your work, copy and paste your responses from the chunk into the form fields below each challenge.

  • You are responsible for correctly coping and pasting only the required code to solve each challenge We will grade only what you have submitted!

  • We will only grade 1 submission per student so do not click Submit until you are confident in your responses.

  • By submitting this form you are certifying that you have followed the academic integrity guidelines available in the syllabus. The code and answers submitted are the results of your work and your work only!

  • Make sure you have completed all the challenges and included all the required personal information (e.g., full name, email, zid) in the respective form’s fields. If you don’t know/want to complete a challenge just leave the field below it empty.

  • Now you are ready to click the above “Submit” button. Congrats you have completed this set of challenges!!!