Question: Problem 5 (Medium) : Generate the code to convert the following data frame to wide format. # A tibble: 4 6 grp sex meanL sdL
Problem 5 (Medium): Generate the code to convert the following data frame to wide format.
# A tibble: 4 6 grp sex meanL sdL meanR sdR1 A F 0.225 0.106 0.34 0.0849 2 A M 0.47 0.325 0.57 0.325 3 B F 0.325 0.106 0.4 0.0707 4 B M 0.547 0.308 0.647 0.274
The result should look like the following display.
# A tibble: 2 9 grp F.meanL F.meanR F.sdL F.sdR M.meanL M.meanR M.sdL M.sdR1 A 0.225 0.34 0.106 0.0849 0.47 0.57 0.325 0.325 2 B 0.325 0.4 0.106 0.0707 0.547 0.647 0.308 0.274
Hint: use pivot_longer() in conjunction with pivot_wider()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
