Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7671719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:07:19+00:00 2026-05-31T16:07:19+00:00

How do I create an xts object whose indexes include milliseconds? I can’t find

  • 0

How do I create an xts object whose indexes include milliseconds? I can’t find any format spec in the POSIXlt help page but there is a reference to %OS in indexFormat().

UPDATE

xts example based on Gavin zoo answer:

> options(digits.secs = 3)
> data(sample_matrix)
> sample.xts = xts(sample_matrix, Sys.time() + seq(0, by = 0.1, length = 180))
> head(sample.xts)
                            Open     High      Low    Close
2012-03-20 08:49:02.820 50.03978 50.11778 49.95041 50.11778
2012-03-20 08:49:02.920 50.23050 50.42188 50.23050 50.39767
2012-03-20 08:49:03.020 50.42096 50.42096 50.26414 50.33236
2012-03-20 08:49:03.120 50.37347 50.37347 50.22103 50.33459
2012-03-20 08:49:03.220 50.24433 50.24433 50.11121 50.18112
2012-03-20 08:49:03.320 50.13211 50.21561 49.99185 49.99185
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:07:20+00:00Added an answer on May 31, 2026 at 4:07 pm

    This works with package zoo so I suspect it works also with xts as the latter builds upon the former.

    > ## create some times with milliseconds
    > times <- Sys.time() + seq(0, by = 0.1, length = 10)
    > times
     [1] "2012-03-19 22:10:57.763 GMT" "2012-03-19 22:10:57.863 GMT"
     [3] "2012-03-19 22:10:57.963 GMT" "2012-03-19 22:10:58.063 GMT"
     [5] "2012-03-19 22:10:58.163 GMT" "2012-03-19 22:10:58.263 GMT"
     [7] "2012-03-19 22:10:58.363 GMT" "2012-03-19 22:10:58.463 GMT"
     [9] "2012-03-19 22:10:58.563 GMT" "2012-03-19 22:10:58.663 GMT"
    > ZOO <- zoo(1:10, order = times)
    > index(ZOO)
     [1] "2012-03-19 22:10:57.763 GMT" "2012-03-19 22:10:57.863 GMT"
     [3] "2012-03-19 22:10:57.963 GMT" "2012-03-19 22:10:58.063 GMT"
     [5] "2012-03-19 22:10:58.163 GMT" "2012-03-19 22:10:58.263 GMT"
     [7] "2012-03-19 22:10:58.363 GMT" "2012-03-19 22:10:58.463 GMT"
     [9] "2012-03-19 22:10:58.563 GMT" "2012-03-19 22:10:58.663 GMT"
    

    The trick to see the milliseconds is to alter the digits.secs option via options(). The above performed using:

    > getOption("digits.secs")
    [1] 3
    

    Which is set using

    > opts <- options(digits.secs = 3)
    

    You can reset this to default (0) by doing options(opts). By default R doesn’t print sub-second information because digits.secs defaults to 0. The data are recorded to sub-second accuracy though, even if not printed.

    If this is not what you meant, can you explain what you did that was not working?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to create an xts object from a data.frame and preserve
I have a R xts timeseries. How can I create a new timeseries from
First I read-in a csv and create an xts object. require(quantmod) sugar <- as.xts(read.zoo(SUGAR.CSV,
// create a style element $(#main).html('<style id=custom_persona_css></style>'); $(#custom_persona_css).append('#abc{ color:#000000; }'); As you can tell,
create table d(id numeric(1), code varchar(2)) After I create the above table how can
x is an xts object full of data; let's assume OHLC data for the
create unique index In DB2 UDB I can create an index using the following
I have 3 xts objects all of whose indicies are 'Date' objects: > a
create table person ( name varchar(15), attr1 varchar(15), attr2 varchar(1), attr3 char(1), attr4 int
Create a flat text file in c++ around 50 - 100 MB with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.