Weekly Coding Checkup 2

A Semester Project made by Custom Designed Activities

We continue working on the Dr. B & Class project. During the entire semester you will apply what we learned in class in a set of tasks and scenarios custom designed for you. Please remember that it is important that the code that you submit is your own code and not somebody else work. It is fine to make mistakes but only by practicing in R you can get a better grasp of the software. I also want you to try building your document as an official report for a potential company (Dreaming Diamonds LLC) for which you are getting to know and explore the diamonds dataset (e.g., spend time on storytelling, commenting results and providing insights and conclusions when possible).

Summary of this week tasks:

This week we enter the world of data manipulations. In an ideal world, you would receive a dataset ready for analysis. However, this is almost never the case. Cleaning and wrangling data are critical skills of data scientists and should be performed before moving to modeling. So, let’s practice what we covered this week: - Getting to know your data - Manipulating your data using the 5 + 1 dplyr functions

TIP: Use the diamonds dataset to solve the below tasks.

Q1: Load the tidyverse package. (1 point)

Q2: Explore the diamonds dataframe using the “Get to Know your Data” functions covered in class. [Hint: try ?diamonds etc. ] (1 point)

Q2b1: How many columns does this dataframe have? (1 point)

Q2b2: How many rows? (1 point)

Q2b3: Do you understand what data each column represents? (no points)

Q3: Keep in the diamonds dataset only the columns that start with the letter “c”. (1 point)

Q3b: How many columns are left in the dataframe? (1 point)

Q4: Keep in the diamonds dataset only the diamonds with price above 1500$ and carat equal to 0.7. (1 point)

Q4b: How many observations are left in the dataframe? (1 point)

Q5: Sort the diamonds dataset from the smallest to the biggest price value. (1 point)

Q5b: What is the lowest selling price? (1 point)

Q6: Calculate the mean, median, and standard deviation of the ‘carat’ column in the diamonds dataframe, storing the results as ‘avg_carat’, ‘median_carat’, and ‘sd_carat’ respectively. [Hint: use ?sd to learn how to compute the standard deviation] (1 point)

Q6b: What is the median carat of the diamonds in your dataframe? (1 point)

Q7: Create a new variable named “price_per_depth”. The price_per_depth column is equal to price divided depth. Make sure the column is added to diamonds dataset. (1 point)

Q8: Keep in the diamonds dataset only the first 5 columns. (1 point)

Q8b: How many columns are left in the dataframe? (1 point)

Q9: Sort the diamonds dataset from the biggest to the smallest carat value. (1 point)

Q9b: What is the biggest carat value? (1 point)

Q10: Keep in the diamonds dataset only the diamonds with “ideal” cut and carat smaller or equal 0.7. (1 point)

Q10b: How many observations are left in the dataframe? (1 point)

Q11: Calculate the average price for each diamond color. Create an object named ‘by_color’ to organize the data at the color level, then compute and store the mean prices as ‘avg_price’. [Hint: two manipulation functions are needed for this task]. (1 point)

Q11b: What color has the highest average price? (1 point)

🛑 Don’t Click Submit Just Yet 🚧

Please read carefully the below information:

  • Once you have completed all the coding questions, and you are confident in your work (take advantage of the immediate feedback feature), copy and paste your responses from the chunk into the form fields below each question.

  • You are responsible for correctly coping and pasting only the required code to solve each question. 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 questions and included all the required personal information (e.g., full name, email, zid) in the respective form’s fields.

  • Now you are ready to click the above “Submit” button. Congrats you have completed your weekly coding check up!!!