The below image is a representation of the data set. I tried using reshape and pivot_wider to widen the data but could not get the result in a manner which I expected. I tried Merging multiple rows into single row from the stack overflow but found that the solution was wrong.
The below image is the expected result that I want from the dataset.
Code for the random dataset generation :
df1 <- data.frame(Components = c(rep("ABC",5),rep("BCD",5)),
Size = c(sample(1:100,5),sample(45:100,5)),
Age = c(sample(1:100,5),sample(45:100,5)))