[tech-spec] Problems with DateTime Classes-
- From: "Vincent C. Fulco" <vfulco@xxxxxxxxxxxxx>
- To: tech-spec@xxxxxxxxxxxxx
- Date: Wed, 30 Mar 2005 14:13:17 -0500
Dear R-gurus-
I continue to be flummoxed by several date/time class issues and their
manipulation even though I've run thru the material/R-help lists a
number of times and have been given a pointer or two from the best R
users on this list. It remains a major roadblock and I wonder if anyone
could give me a link to some material which might help?
For example, trying to do a simple rolling correlation of two time
series using the "its" (function priceIts) and "fSeries" (roll functions
to start before I calculate correlations) libraries. I use "its" to
import data from yahoo and the material clearly states "...The object
consists of a matrix, with a single slot, the named POSIX vector named
'dates'..."
library(its)
library(fSeries)
#
intc.2005<- priceIts(instrument=c("INTC"), start="2005-01-01", quote =
"Close")
str(intc.2005)
#
# which produces-
#
str(intc.2005)
Formal class 'its' [package "its"] with 118 slots
num [1:59, 1:2] 23.1 22.6 22.4 22.5 22.8 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:2] ".Data" "dates"
# At this point, the "dates" appear to be in "character" format and not
in POSIX to the best of my knowledge. So it needs to be manipulated
further. However, when i try to coerce it to as.POSIXlt etc, I get an
error message...
> intc.2005<- as.POSIXlt(date)
Error in as.POSIXlt(date) : Don't know how to convert `date' to class
"POSIXlt"
# Additionally, if I try another fSeries Function (getReturns) which
manipulates the raw time series (intc.2005) into a returns vector...
> ret.intc.2005<-getReturns(intc.2005)
Error in its(x, dates = attributes(x)$dates) :
dates should be in POSIX format
I realize this is very rudimentary but I can't frame the date/time
manipulation properly.
Thanks all,
Vince Fulco
Other related posts: