I have a data frame in the below format Original format
For a given ID; the age ,sex and status remain the same.
I want to do a couple of transformations
- Have a single row for each "Id" and "Type".
- Find unique values in "Tablet" column and do a transpose .
- Transpose "Level" column and have the values corresponding to each tablet under newly transposed tablet column.Empty cells have to be filled with "NA".
The desired output format is attached below for reference.desired format
I have tried using dcast and reshape; tidyr with dplyr using gather and spread,however am not able to acheive the 3rd transformation
Any help would be great! Thanks