Tidy Data
Due: Sep 08 by 11:59pm
Weight: This assignment is worth 1% of your final grade.
Purpose: The purpose of this assignment is to introduce yourself to the “tidy data” concept and to practice modifying data frames between long and wide formats in R.
Assessment: This assignment is graded using a check system:
- ✔+ (110%): Responses shows phenomenal thought and engagement with the course content. I will not assign these often.
- ✔ (100%): Responses are thoughtful, well-written, and show engagement with the course content. This is the expected level of performance.
- ✔− (50%): Responses are hastily composed, too short, and/or only cursorily engages with the course content. This grade signals that you need to improve next time. I will hopefully not assign these often.
Notice that this is essentially a pass/fail system. I’m not grading your writing ability and I’m not counting the number of words you write - I’m looking for thoughtful engagement. One or two sentences is not enough. Write at least a paragraph and show me that you did the readings assigned.
1. Get Organized
Open your course repo (eda-f26/eda-netID) in Positron using File › Open Folder - open the folder itself, not a file inside it. If you haven’t cloned your course repo yet, follow the steps in HW1 first.
Everything for this assignment lives in the hw2 folder. Open the hw2.qmd file inside it - that’s the only file you need to edit. Take notes and write example code under the “Begin notes here” heading as you go through the readings and exercises below, then write your reflection under the “Reflection” heading at the end.
2. Readings & Exercises
- Getting Familiar with Tidy Data: Read this tidyverse article explaining the concept of tidy data. In your
hw2.qmd, copy some of the examples into a code chunk and run them to see the results of converting data between long and wide formats. - Use AI to Practice Reshaping Messy Data: Using an agent, ask for help creating a demo to practice the concept of reshaping data into long and wide formats in R using the tidyverse. Your agent should directly edit the
hw2.qmdfile. Once you have some examples to work with, ask the agent questions about reshaping data to make sure you understand the concept. Here is an example prompt to try (feel free to experiment with other prompts):
I'm practicing the concept of tidy data in R. Provide me an example dataset in wide format and then show me R code for how to convert it to long format using the tidyverse. Afterwards, do the opposite - show me an example of a dataset in long format and show me R code for how to convert it to wide format. In each case, explain your reasoning in addition to writing the code. Directly edit the hw2.qmd file.
Optional
- Chapter 6 in Hadley Wickham’s R4DS book covers more detail on the concept of tidy data with even more examples. It’s worth reading through for a more comprehensive understanding.
- Chapter 3 in the YARDBook also covers tidy data.
- Chapter 29 in Hadley Wickham’s R4DS book is a great introduction to Quarto. I highly recommend taking a look through it to get a better understanding of Quarto if you’re still not quite comfortable with it (we’ll be using it the whole semester!).
3. Reflect
Reflect on what you’ve learned while going through these readings and exercises. Is there anything that jumped out at you? Anything you found particularly interesting or confusing?
Write at least a paragraph in your hw2.qmd file, and include at least one question. The teaching team will review the questions we get and will try to answer them either in Slack or in class.
Some thoughts you may want to try in your reflection:
- “I used to think ______, now I think ______ 🤔”
- Discuss some of the key insights or things you found interesting in the readings or recent class periods.
- Connect the course content to your own work or project you’re working on.
4. Submit
To submit your assignment, follow these instructions:
- Render your .qmd file by either clicking the “Preview” button in Positron or running
quarto renderin the terminal. - Open the rendered html file and make sure it looks good! Is all the formatting as you expected?
- Commit and push your work using GitHub Desktop: look at the diff, write a short commit message, click Commit, then Push.
Your work isn’t submitted until you’ve pushed it. Committing only saves the change on your own computer – go look at your repo on GitHub.com and confirm your work is actually there before you call this done.