[R-SIG-Finance] Problems with xts and plotting charts in quantmod

Wouter Thielen wouter at morannon.org
Thu Feb 5 02:23:46 CET 2015


Hi Carlos,

I can not clearly see where the columns start or stop, but I hope that the
first character (1, 2, 3, 4) is a separate column, and that the date+time
is in the second column. If that is the case, try passing
"index=as.POSIXct(data$V2, format='%Y%m%d %H%M%S')" to your as.xts function:

as.xts(data, index=as.POSIXct(data$V2, format='%Y%m%d %H%M%S'))

You may want to skip the first column as it is not part of the OHLC
structure, so as.xts(data[, -1], index=...).

For more reference, see http://www.stat.berkeley.edu/~s133/dates.html and
http://stackoverflow.com/questions/18261160/convert-date-time-format-for-use-in-xts

Hope this helps.

Wouter

On Thu Feb 05 2015 at 10:09:38 AM Liu <carloslewlew at gmail.com> wrote:

> Hi all,
> I'm trying to plot candle charts from OHLC data frame like this:
>  V1V2V3V4V5
> 120150101 1801001184.131184.441184.041184.13
> 220150101 1802001184.121184.411184.121184.41
> 320150101 1803001184.531184.541184.321184.54
> 420150101 1804001184.601184.601184.431184.51
> Tried to cast it to xts by using:
>
> data<-read.csv(file path)
> chartSeries(as.xts(data),type="candlesticks")
>
> Then I have the error "
>
> Error in as.POSIXlt.character(x, tz, ...) :
>   character string is not in a standard unambiguous format
>
> "
> I am not sure what that means. Maybe it's saying that my date and time is
> non standard string? What should I do?
> Please help.
>
> Thanks
> Carlos
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>

	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list