I have a data frame of housing values spanning over 20~ years. The column names are the months and years i.e. 04-1996, 05-1996, 06-1996
and so on. I want to plot time series data for those months and years and have to take those column names and plot them into the resulting data frame.
I tried this to test it out:
df2<-melt(df, na.rm=T, id.vars=c("RegionName","CountyName"), measure.vars=c("04-1996", "05-1996", "06-1996"))
And it gave me the years and such in the respective rows, which is good. I'm close.
I currently have:
Region City Apr-1996 May-1996 June-1996
1 10025 New York 10000 10000 10000
2 10023 New York 10000 10000 10000
3 10128 New York 10000 10000 10000
All the way until May 2015.
I would ideally like something that looks like:
Region City Month Year Value
1 10025 New York 04 1996 123100
2 10023 New York 05 1997 72700
3 10128 New York 06 1998 91600
I'm seeing errors saying Error: id variables not found in data: Month-Year
when I tried adding id.vars
to my melt.
But when I go to create a for loop to go through all the column names, it craps out on me giving me errors. Any direction would be awesome.