R Combine Multiple Rows of DataFrame by creating new columns and union values
1
1
$begingroup$
I have a dataframe in R that looks like this ID APPROVAL_STEP APPROVAL_STATUS APPROVAL_DATE APPROVER 1234 STEP_A APPROVED 23-Jan-2019 John Smith 1234 STEP_B APPROVED 21-Jan-2019 Jane Doe I need it to look like this ID STEP_A_STATUS STEP_A_APPROVAL_DATE STEP_A_APPROVER STEP_B_STATUS STEP_B_APPROVAL_DATE STEP_B_APPROVER 1234 APPROVED 23-Jan-2019 John Smith APPROVED 21-Jan-2019 Jane Doe And of course, with the original dataframe, any of APPROVAL_STATUS, APPROVAL_DATE, or APPROVER can be NA. What is the most elegant way to do this? I know how to do it by looping through the unique IDs, grabbing each row, creating new columns, etc.; but is there any way to do this in a more ...