I'm working in R, and trying to restructure a data frame that currently has excess info and duplicate cases. What I want is for each person to
A) have their own row, instead of each person x case to have its own row. So in the example below, it would be B2 F USA Beginner Honda Luxury Yes Audi Sport Yes ... and so on all in one row. The second row would begin with B3.
B) And each new column would have a name, e.g.,
Car Car Type Bought Car_2 Car Type_2 Bought_2
Honda Luxury Yes Audi Sport Yes
C) And delete the rows with just the descriptive info that stays constant (i.e., Driver, Gender, Country, License).
I have nearly 200 cases to do this for, so I'm thinking I need a solution that involves some coding vs. my traditional method of copy & paste. Any assistance would be appreciated!
Example:
Driver Gender Country License Car Car Type Bought
B2 F USA Beginner Honda Luxury Yes
B2 F USA Beginner Audi Sport Yes
B2 F USA Beginner BMW Family Yes
B2 F USA Beginner Bugatti Sport No
B2 F USA Beginner Buick Family No
B3 M USA Advanced Honda Family Yes
B3 M USA Advanced Audi Luxury No
B3 M USA Advanced BMW Sport No
B3 M USA Advanced Bugatti Family Yes
B3 M USA Advance Buick Luxury Yes