[R] xts POSIXct index format

Joshua Ulrich josh.m.ulrich at gmail.com
Mon Mar 7 02:02:38 CET 2011


Hi David,

On Sat, Mar 5, 2011 at 11:00 PM, David Winsemius <dwinsemius at comcast.net> wrote:
>
> On Mar 5, 2011, at 11:28 AM, Joshua Ulrich wrote:
>
>> Hi Chris,
>>
>> Perhaps something like this?
>>
>> require(xts)
>> ds <- options(digits.secs=6) # so we can see sub-seconds
>> x <- xts(1:10, as.POSIXct("2011-01-21") + c(1,1,1,2:8)/1e3)
>> x
>> indexFormat(x) <- "%H:%M:%OS3"
>> x
>>
>
> Joshua;
>
> Does your reading of help(indexFormat) lead you to that suggestion? When I

I didn't read the documentation.  I remembered the functionality from
conversations with Jeff Ryan.

> read it I thought that indexFormat would only accept onoe of " Date,
> POSIXct, chron,yearmon, yearqtr or timeDate." Those were the formats

Those are the classes available to use with indexClass<-, which
controls the class returned by index().

> mentioned in the immediately preceding paragraph. I went to the help page
> hoping I would be told I could use format strings but left it thinking that
> I could only specify format classes.
>

We could probably make the use of format strings more explicit (via an
example?).  Do you have any suggestions to help clarify the prose?

> --
> David
>
>

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com


>> Hope that helps,
>> --
>> Joshua Ulrich  |  FOSS Trading: www.fosstrading.com
>>
>>
>>
>> On Fri, Mar 4, 2011 at 5:57 PM, rivercode <aquanyc at gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I cannot figure out how to change the index format when displaying
>>> POSIXct
>>> objects.
>>>
>>> Would like the xts index to display as %H:%M:%OS3 when doing viewing the
>>> xts
>>> object.
>>>
>>> Think I am missing the obvious.
>>>
>>> Cheers,
>>> Chris
>>>
>>> --
>>> View this message in context:
>>> http://r.789695.n4.nabble.com/xts-POSIXct-index-format-tp3336136p3336136.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>



More information about the R-help mailing list