[R] tseries object

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Dec 25 14:00:14 CET 2001


ozric at web.de wrote:
> 
> Hello,
> what's the problem with the dimnames - i get no solution ?
> thanks for advance, regards
> christian
> 
> > file <- read.table("c:/rw1040/data/timeSeries.txt",header=T)
> > file
>      DATE   AQ  EUMS
> 1   Jan92  7.6  98.4
> 2   Feb92  7.5  98.5
> 3   Mrz92  7.5  97.0
> ....................
> 117 Sep01  9.4 105.3
> 118 Okt01  9.5 102.6
> 
> > file.ts <- ts(file,start=c(1992,1),end=c(2001,10),frequency=12)
> Error in "dimnames<-.data.frame"(*tmp*, value = list(NULL, names)) :
>         invalid dimnames given for data frame
> > file.ts <- ts(file,start=c(1992,1),frequency=12)
> Error in "dimnames<-.data.frame"(*tmp*, value = list(NULL, names)) :
>         invalid dimnames given for data frame


>From ?ts:
data 	a vector or matrix of the observed time-series values. 

So it is not documented that a dataframe will work as data argument for
ts().
Turning the dataframe into a matrix(as.matrix()) should work:

file.ts <- ts(as.matrix(file), start=c(1992,1), frequency=12)

Uwe
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list