I’ve found some information about xts fields representation in this thread but I’m still not clear why xts is an index + a matrix. Why not an index + a data frame? Wouldn’t that allow more flexibility when working with factors and numeric columns?
Once I’ve loaded data in xts most of the work consists in performing numerical operations on a full set or a subset of the time series. For this the indexing works very well, but I am forced to go through calls like data.frame(data.matrix(myxts)) to be able to extract factors and numerical columns.
In addition I find more convenient to use the $ notation than the matrix indexing, although this is really a different question. For example:
lm(myxts$Res ~ myxts$ThisVar + myxts$ThatVar)
is easier to write than
lm(myxts[, "Res"] ~ myxts[, "ThisVar"] + myxts[, "ThatVar"]).
xts uses matrix rather than data.frame because:
Your second question could be solved by using the
data=argument tolmor, more generally, by usingwith: