In python
, and more specifically in pandas
, I can work with MultIndex
on rows or columns. Is there an equivalent in R
? I was checking several tutorials, such as the one in https://en.wikibooks.org/wiki/R_Programming/Working_with_data_frames, but I couldn't find a proper R
equivalent.
As an example I have the following data frame:
A-1 A-2 B-1 B-2
0 1 2 0 1
1 2 0 1 3
2 4 1 3 2
I want it to look like:
A B
1 2 1 2
0 1 2 0 1
1 2 0 1 3
2 4 1 3 2
Other relevant answers I have found from stackoverflow