Section 1. Chapter 8
single
Challenge: Transforming and Recoding Variables
Swipe to show menu
Task
Swipe to start coding
Practice transforming and recoding variables in a simulated dataset using mutate() and case_when().
- Use
mutate()to create a new variable,score_scaled, which is thescoredivided by 100. - Create a new variable,
group_label, usingcase_when()to recode thegroupvariable: "A" becomes "Control", "B" becomes "Treatment", and any other value becomes "Unknown". - Return the resulting data frame with the new variables.
Solution
Everything was clear?
Thanks for your feedback!
Section 1. Chapter 8
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat