2

I'm attempting to reshape the AirPassengers dataset on R from wide to long.

data(AirPassengers)
melt(AirPassengers)

The issue I am encountering is that 'melt' keeps the value of the AirPassengers data but I need the corresponding time information alongside the output of melt(AirPassengers).

What is the best method to reshape time series data while keeping a time column?

Thank you!

treenode
  • 21
  • 1
  • 2
    Just so you know, `AirPassengers` does not have dimensions or columns - they are added by the `ts` timeseries printing - compare `print.default(AirPassengers)` and `print(AirPassengers)` - would `cbind(time(AirPassengers), AirPassengers)` be sufficient? – thelatemail May 06 '16 at 05:45
  • that's exactly what I was after, thank you! I had a hard time figuring out why dim(AirPassengers) was always returning NULL, the `ts` timeseries format was doing my head in. Much appreciated. – treenode May 06 '16 at 05:53

0 Answers0