0

I have following matrix:

                   value1             value2              value3 
2001 Q1            9.25                26.45               26.64 
2001 Q2            9.25                25.67               26.50 
2001 Q3            9.50                23.15               23.49 
2001 Q4           10.00                20.30               20.43 

I confirm its a matrix:

 class(dataMat)
[1] "mts"    "ts"     "matrix"

What I am little confuse about the column that has year and the quarter when I write to file using zoo, I don't see the year and the quarter at all. Due to this I tried to convert this matrix in to data.frame. Unfortunately Year and Quarter disappear instead I get numerical index in data frame.

data.frame(dataMat)

How do I convert above data matrix to a data frame.

In addition I am little bit confuse about this data structure: If I do fallowing I get 4 quarters which tells me underline data structure has some notion of time series.

> dataMat[,1]
      Qtr1  Qtr2  Qtr3  Qtr4
2001  9.25  9.25  9.50 10.00
add-semi-colons
  • 18,094
  • 55
  • 145
  • 232

1 Answers1

0

Part of the issue seems to be that the first row is actually the row names. You can extract them using rownames(dataMat).

Mhairi McNeill
  • 1,951
  • 11
  • 20