as.POSIXct issue
Then my guess is that your date column is a factor, not character. as.POSIXlt.factor doesn't pass dots, which is why your specified format wasn't affecting anything. -- Joshua Ulrich ?| ?FOSS Trading: www.fosstrading.com On Wed, Dec 29, 2010 at 12:21 PM, Nick Torenvliet
<nick.torenvliet at gmail.com> wrote:
Yes, I did all that... I am having trouble deciphering, in as.xts what is passing what to what to what and in what required format though... so as I say my experimentation with formats and strptime has left me cold... On Wed, Dec 29, 2010 at 1:14 PM, Joshua Ulrich <josh.m.ulrich at gmail.com>wrote:
This is really more suited for R-help. ?I'm surprised you weren't able
to find the answer in the documentation.
From ?as.POSIXct:
?format: character string giving a date-time format as used by ?strptime?.
Which points you to 'strptime'. ?From ?strptime:
?format: A character string. ?The default for the ?format? methods is
? ? ? ? ??"%Y-%m-%d %H:%M:%S"? if any component has a time component
? ? ? ? ?which is not midnight, and ?"%Y-%m-%d"? otherwise. ?If
? ? ? ? ??options("digits.secs")? is set, up to the specified number
? ? ? ? ?of digits will be printed for seconds.
--
Joshua Ulrich ?| ?FOSS Trading: www.fosstrading.com
On Wed, Dec 29, 2010 at 12:09 PM, Nick Torenvliet
<nick.torenvliet at gmail.com> wrote:
Hey all, happy new year to everyone! Little problem with some intraday data... I am working with a data.frame with the following format ? ? ? ? ? ? ? ? Date ? ? ? ? ?amp1 ? ? ?amp2 ? ? ? amp3 ? ? ?amp4 amp5 ? ? ?amp6 1 19-10-2010 10:00:00 107.9531 105.6093 107.7965 109.1090 105.7922
107.4480
2 ?19-10-2010 9:00:00 110.4417 104.5610 106.9595 108.7497 105.5956
106.2880
3 ?19-10-2010 8:00:00 107.9917 105.0005 107.3482 108.6856 105.7174
107.6556
4 ?19-10-2010 7:00:00 109.1250 105.3563 107.8153 106.7011 106.5455
107.4221
5 ?19-10-2010 6:00:00 106.9048 104.7166 107.6824 106.0305 105.4604
108.3743
6 ?19-10-2010 5:00:00 108.2507 105.9069 107.6404 107.9394 106.0853
108.6718
I would like to convert to xts So I do something like
xamps <- as.xts(amps[,-1],order.by=as.POSIXct(amps[,1]))
and get
head(xamps)
? ? ? ? ? ? ? ? ?amp1 ? ? ?amp2 ? ? ? amp3 ? ? ?amp4 ? ? ?amp5 ? ? ?amp6 0009-10-20 111.4689 109.7270 106.1861 106.6256 106.0793 103.8423 0009-10-20 108.7130 109.9188 105.9373 106.9048 104.9599 104.5320 0009-10-20 109.7888 110.9390 107.3443 103.5092 105.9069 104.9364 0009-10-20 108.3422 110.2832 105.6447 106.0327 105.0138 103.5630 0009-10-20 109.1262 109.6370 106.2502 106.6233 104.6663 103.3754 0009-10-20 108.1395 110.4855 105.2810 104.1202 105.0546 103.2907 I've narrowed the issue down to the as.POSIXct statement... and have consulted the literature/experimented to no avail. So what arguments do I need to supply the as.POSIXct to convert a
character
vector fomatted as "dd-mm-YYYY hh:mm:ss" to an equivalent xts index? Thanks in advance, Nick ? ? ? ?[[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]]
_______________________________________________ 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.