Maybe this can't even be done because I have my data in a bad format, but I'm trying to get it from a "kind of" wide format to a long format. If I modify the data in excel first, I know how to do this with melt, but I have a LOT of data, and I'm hoping to not have to modify it all by hand first.
Basically I have my headers have depth where I have multiple descriptors for each column of sales. Account, Brand, Variety and Tier (and maybe some others as well depending on how this goes)
Account
Brand
Variety
Tier
Dates
1/1/2011 Sales xxx
2/1/2011 Sales xxx
And the format I need it in would be
Date Account Brand Variety Tier Sales
I don't understand how to convert this using reshape or melt though. Any suggestions, or do I just have to do it by hand?
EDIT
Actual data looks something like this (names changed to protect the innocent)
Account Account A Account A Account A Account A Account B
Brand Brand A Brand A Brand B Brand B Brand C
Variety Cab Chard Merlot Pinot Grigio Pinot Noir
Tier Tier 2 Tier 3 Tier 2 Tier 1 Tier 3
Date
6/1/20 35 47 35 28 -
7/1/2011 12 17 12 12 84
8/1/2011 - - - - -
9/1/2011 7 7 7 7 84
10/1/2011 28 28 28 28 112
11/1/2011 168
12/1/2011 7 7 7 7 224
1/1/2012 14 236
If I massage it in excel to look like this
Date Compilation_Red Compilation_White Oak_Cab Oak_Chard
1 11/1/2012 351 140 183 190
2 12/1/2012 191 99 120 92
3 1/1/2013 96 56 87 51
4 2/1/2013 30 30 84 61
5 3/1/2013 96 70 100 57
6 4/1/2013 60 38 52 22
7 5/1/2013 12 17 65 49
8 6/1/2013 9 7 28 21
9 7/1/2013 16 13 23 22
10 8/1/2013 26 29 40 33
11 9/1/2013 14 4 30 23
12 10/1/2013 17 4 47 31
13 11/1/2013 23 5 63 35
14 12/1/2013 25 3 70 41
15 1/1/2014 44 1 88 41
16 2/1/2014 28 7 57 43
Then I know how to use melt to get it into long format
myItem=melt(Account, id.vars="Date", variable.name="Variety", value.name="Sales")
I just don't understand how to deal with all the extra headers, and get them into the long format.
Also, I don't understand why my table looks fine when I put it in, but is mashed together in the preview.