Here is the dummy code.
x = data.frame(
control_type = c("case","control","control"),
gender = c("M","F","M"),
short = c(1,2,3),
medium = c(5,7,4),
long = c(9,12,10)
)
I want to get this data frame to look like the image below, but I cannot seem to figure out how to do it. In other words, convert the top part of the image to the bottom. Possibly using melt in some way? I am not sure.