I have one csv file with four columns, and the first row is the category for each column of expenses:
Category, A1, A2, A3 Date, Expenses, Expenses, Expenses 05/01/2014, 122.33, 123.35, 155.12 05/02/2014, 123.64, 165.54, 134.45 05/03/2014, 134.35, 123.54, 154.65 05/04/2014, 134.67, 415.56, 134.45 05/05/2014, 145.89, 145.34, 123.46
I want to group the data in this form in R:
Date Category Expenses 05/01/2014 A1 122.33 05/02/2014 A1 123.64 05/03/2014 A1 134.35 05/04/2014 A1 134.67 05/05/2014 A1 145.89 05/01/2014 A2 123.35 05/02/2014 A2 165.54 05/03/2014 A2 123.54 05/04/2014 A2 415.56 05/05/2014 A2 145.34 05/01/2014 A3 155.12 05/02/2014 A3 134.45 05/03/2014 A3 154.65 05/04/2014 A3 134.45 05/05/2014 A3 123.46
I have tried separating the file into categories and then the expenses, but don't know how to merge rows from one data frame with rows from another. The resulting data frame would be around 9 million rows, so I don't know whether a for loop would be convenient.