[R] Problem converting zoo object (daily data) to a timeSeries object

Gabor Grothendieck ggrothendieck at gmail.com
Fri Jan 28 05:50:40 CET 2011


On Thu, Jan 27, 2011 at 11:56 AM, John E. Kaprich <jkaprich at gmail.com> wrote:
> When I try to convert the zoo object to a timeSeries object, which would
> allow me to utilize Rmetrics packages, I get an error message.
>
>
>
>> Data<-read.zoo("c:\\DOWUBSPRICING.txt,na.strings="NA",sep="\t",header=T)
>> is(Data)
> "zoo"
>> as.timeSeries.zoo(Data)
> Error in .local (.Object, . )
>
> Is this happening because I am using daily data? Originally, I was trying to
> import the data as a timeSeries, but could not overcome problems with the
> date configuration. I tried to create a zoo object with the intention of
> converting it into a timeSeries.
>
> My apologies if this is too basic a question, but I am new to R and have
> been struggling with this problem.
>
> The object in question contains daily adjusting closing price data.
>
>                                DJP         JJA          COW
>
> 2011/1/21            49.01     64.68     30.97
> 2011/1/20            48.62     63.78     31.11
>
> .


There are a different number of headings and columns so the dates are
being interpreted as row names. Try this:

Lines <- " DJP         JJA          COW
2011/1/21            49.01     64.68     30.97
2011/1/20            48.62     63.78     31.11"

library(zoo)
DF <- read.table(textConnection(Lines))
z <- zoo(DF, rownames(DF))


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list