0

Say you have

Name     August   September   October     November
Bob        5          4          3            2
George     3          2          2            4 
Gina       1          4          2            1

And you want to convert into 3 columns like so

Name     Month       Output
Bob      August        5
Bob      September     4
.....

I see how to do it in VBA through the following link : https://www.extendoffice.com/documents/excel/2773-excel-convert-matrix-to-list.html

Unsure how to execute in R. All of the searching I've yielded want to simply split the matrix into vectors which isn't correct.

bosois
  • 21
  • 4

1 Answers1

0

If you have a dataframe, say, df you can define its column names as a column in its own right by using names:

df$Month <- names(df)[2:5]
Chris Ruehlemann
  • 20,321
  • 4
  • 12
  • 34