Let us say I have a data frame as follows:
data <- data.frame("Company" = c("X", "Y"),
"Chocolate" = c(1, 2),
"Vanilla" = c(2 ,1))
data
Company Chocolate Vanilla
1 X 1 2
2 Y 2 1
How do I reshape this data.frame into the format below:
Company Type
X "Chocolate"
X "Vanilla"
X "Vanilla"
Y "Chocolate"
Y "Chocolate"
Y "Vanilla"
I am attempting to make an empty data frame then somehow using a "for" loop, but I struggle to understand how to make it work