[R-sig-finance] Trouble with zoo + POSIXct/POSIXlt

icosa atropa icos.atropa at gmail.com
Tue Apr 18 07:48:31 CEST 2006


After successfully using the 'its' package, I've been trying out 'zoo'
for some of its more advanced functions.  I can coerce my its objects
into zoo objects without problem.
Yet I'm having trouble understanding the read.zoo function's errors.
It seems that my index class, POSIXct, is the problem.

I have csv files like this:
7/23/2003 4:05:51 PM,9.35,98.027
7/23/2003 4:20:51 PM,9.32,97.954

-----------------------
#First try:
>my.format = "%m/%d/%Y %I:%M:%S %p"
>x=read.zoo(myfile, sep=',', skip=30, format=my.format)
> z
             V2      V3
2003-07-23 9.35  98.027
2003-07-23 9.32  97.954
> summary(z)
Error in "row.names<-.data.frame"(`*tmp*`, value = NULL) :
        invalid 'row.names' length
#format= doesn't seem to work here, error means index not #unique?
#
#Second try,
#This works:
>x=read.table(myfile, sep=',' , skip=30,\
x[,1]=as.POSIXct(strptime(x[,1], format=my.format,\ tz='UTC+6'))
> y=zoo(x[,2:3], order.by=x[,1])
#
#but this doesn't:
#
>x=read.zoo(my.file, sep=',',skip=30,\
FUN=as.POSIXct(strptime(as.character(x), format=my.format,
tz='UTC+6')) )
Error in read.zoo(files[1], sep = ",", skip = 30, FUN =
as.POSIXct(strptime(as.character(x),  :
        couldn't find function "FUN"
---------
Any idea what the last error message means?
TIA,
christian



More information about the R-sig-finance mailing list