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

  • Home
  • SEARCH
  • 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 7728879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:49:44+00:00 2026-06-01T05:49:44+00:00

I am either misunderstanding the docs or having a problem with the drop.time=TRUE parameter

  • 0

I am either misunderstanding the docs or having a problem with the drop.time=TRUE parameter in to.weekly(). For a simple example, add a time component onto some sample daily data and roll it up to weekly:

library(xts)
data(sample_matrix)
d <- as.xts(sample_matrix)
index(d) <- index(d)+50

w1 <- to.weekly(d, drop.time=TRUE)
head(w1,1)
                      d.Open   d.High    d.Low  d.Close
2007-01-07 00:00:50 50.03978 50.42188 49.95041 49.99185

w2 <- to.weekly(d, drop.time=FALSE)
head(w2,1)
                      d.Open   d.High    d.Low  d.Close
2007-01-07 00:00:50 50.03978 50.42188 49.95041 49.99185

The docs say:

Setting drop.time to TRUE (the default) will convert a series that
includes a time component into one with just a date index, as the
time index is often of little value in lower frequency series.

This question mentions that drop.time depends upon indexClass(d)[1] == 'POSIXt' but that appears not to help:

indexClass(d)
[1] "POSIXct" "POSIXt"

indexClass(d) <- c('POSIXt', 'POSIXct')
w3 <- to.weekly(d, drop.time=TRUE, name=NULL)
head(w3,1)
                        Open     High      Low    Close
2007-01-07 00:00:50 50.03978 50.42188 49.95041 49.99185

I’m sure I can just truncate off the time component, but am curious what I’m doing wrong.

  • 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-06-01T05:49:46+00:00Added an answer on June 1, 2026 at 5:49 am

    This has been fixed in r613 on R-forge. xts:::.drop.time was looking for the virtual POSIXt class in the first position of the class attribute, but (at some point) the order of the POSIXct and POSIXt classes had been switched in base R. I tried to make this check more robust to future changes.

    I also made xts:::.drop.time actually change the underlying index. It had been setting indexClass(x) <- "Date", but the underlying index was still the original POSIXt times (including intra-day components). This would cause funky merges.

    library(xts)
    data(sample_matrix)
    d1 <- d2 <- as.xts(sample_matrix)
    index(d1) <- index(d1)+50
    D1 <- to.daily(d1)
    D2 <- to.daily(d2)
    head(merge(D1,D2),2)  # old behavior
                d1.Open  d1.High   d1.Low d1.Close  d2.Open  d2.High   d2.Low d2.Close
    2007-01-02       NA       NA       NA       NA 50.03978 50.11778 49.95041 50.11778
    2007-01-02 50.03978 50.11778 49.95041 50.11778       NA       NA       NA       NA
    head(merge(D1,D2),1)  # new behavior
                d1.Open  d1.High   d1.Low d1.Close  d2.Open  d2.High   d2.Low d2.Close
    2007-01-02 50.03978 50.11778 49.95041 50.11778 50.03978 50.11778 49.95041 50.11778
    

    Thanks for the report and example!

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

Sidebar

Related Questions

I have a feeling I'm either misunderstanding the 'stop' event or not doing it
I have the following code that shows either a bug or a misunderstanding on
Either I'm too stupid to use google, or nobody else encountered this problem so
Either I have misunderstood the jQuery docs for .attr() , or I'm making a
Either i'm going nuts or nobody likes/liked this feature, but a long time ago
When either hiding my tray icon and closing the application, half the time my
I have what is either a bug in log4net, or a misunderstanding on my
Maybe I am being daft, or misunderstanding either WAMP restrictions or browser restrictions, but
I'm having an annoyingly stubborn problem here, and I would appreciate it if anyone
either I'm missing something or the ( patterns & practices Composite Application Guidance for

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.