I would like to change the structure of my dataframe in R. I would have something like this:
df <- data.frame(Letter = c("a", "b", "c", "d", "e"),
Number = c(23, 41, 32, 58, 26)
)
print (df)
Letter Number
1 a 23
2 b 41
3 c 32
4 d 58
5 e 26
I want to append each column content below each other, and then rename the corresponding column with the originating column name. The output would be the following:
Could you please help me?
I would expect the output to be something like this.
A B
1 a Letter
2 b Letter
3 c Letter
4 d Letter
5 23 Number
6 41 Number
7 32 Number
8 58 Number