plot.xts: Error in parse.format(format[1]) : unrecognized format %b %d%n%H:%M:%S
Try plot.zoo as a workaround: library(chron) library(xts) # read data creating xts object x Lines <- "12/07/08 19:46:40,98.04 12/07/08 19:46:41,98.04 12/07/08 19:46:42,98.04 12/07/08 19:46:43,98.04 12/07/08 19:46:44,98.04 12/07/08 19:46:45,98.04 12/07/08 19:46:46,98.04 12/07/08 19:46:47,98.04 12/07/08 19:46:48,98.04 12/07/08 19:46:49,98.04 12/07/08 19:46:50,98.04" z <- read.zoo(textConnection(Lines), sep = ",", FUN = as.chron, format = "%m/%d/%y %H:%M:%S") x <- as.xts(z) # plot it - first one gives error, second works plot(x) plot(as.zoo(x))
On Wed, Dec 10, 2008 at 3:57 PM, <davidr at rhotrading.com> wrote:
I cannot figure out what's wrong here. If someone could shed some light, I'd appreciate it very much. I form an xts object with a chron index (small version here) that seems OK, but I can't plot it:
plot(gesmall)
Error in parse.format(format[1]) : unrecognized format %b %d%n%H:%M:%S
str(gesmall)
An 'xts' object from (12/07/08 19:46:40) to (12/07/08 19:46:50) containing: Data: num [1:11, 1] 98 98 98 98 98 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : NULL Indexed by: Classes 'chron', 'dates', 'times' atomic [1:11] 14221 14221 14221 14221 14221 ... ..- attr(*, "format")= Named chr [1:2] "m/d/y" "h:m:s" .. ..- attr(*, "names")= chr [1:2] "dates" "times" ..- attr(*, "origin")= Named num [1:3] 1 1 1970 .. ..- attr(*, "names")= chr [1:3] "month" "day" "year" xts Attributes: NULL
summary(gesmall)
Index gesmall Min. :(12/07/08 19:46:40) Min. :98.04 1st Qu.:(12/07/08 19:46:42) 1st Qu.:98.04 Median :(12/07/08 19:46:45) Median :98.04 Mean :(12/07/08 19:46:45) Mean :98.04 3rd Qu.:(12/07/08 19:46:48) 3rd Qu.:98.04 Max. :(12/07/08 19:46:50) Max. :98.04
gesmall
(12/07/08 19:46:40) 98.04 (12/07/08 19:46:41) 98.04 (12/07/08 19:46:42) 98.04 (12/07/08 19:46:43) 98.04 (12/07/08 19:46:44) 98.04 (12/07/08 19:46:45) 98.04 (12/07/08 19:46:46) 98.04 (12/07/08 19:46:47) 98.04 (12/07/08 19:46:48) 98.04 (12/07/08 19:46:49) 98.04 (12/07/08 19:46:50) 98.04
# It looks as if there are somehow empty field names; not sure how
that happens or if it's important
sessionInfo()
R version 2.8.0 Patched (2008-11-02 r46817) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] xts_0.0-16 zoo_1.5-4 chron_2.3-24 loaded via a namespace (and not attached): [1] grid_2.8.0 lattice_0.17-15 tools_2.8.0 Thanks, -- David
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.