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 7187619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:53:11+00:00 2026-05-28T18:53:11+00:00

How do I subset an xts object to only include weekdays (Mon-Fri, with Saturday

  • 0

How do I subset an xts object to only include weekdays (Mon-Fri, with Saturday and Sunday excluded)?

  • 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-28T18:53:12+00:00Added an answer on May 28, 2026 at 6:53 pm

    Here’s what I’d do:

    library(xts)
    data(sample_matrix)
    sample.xts <- as.xts(sample_matrix, descr='my new xts object')
    x <-  sample.xts['2007']  
    x[!weekdays(index(x)) %in% c("Saturday", "Sunday")]
    

    EDIT:
    Joshua Ulrich in comments points out a better solution using .indexwday(), one of a family of built-in accessor functions for extracting pieces of the index of xts class objects. Also, like Dirk Eddelbuettel’s solution, the following should be locale-independent:

    x[.indexwday(x) %in% 1:5]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My form includes a subset of Client entity properties and I also include a
What does Client-only Framework subset in Visual Studio 2008 do?
I want to get a subset of a string in Javascript. Currently, I only
I have some imported csv data that I have turned into an xts object.
How do I subset a dataframe so that only rows that contain columns that
I want to run only a subset of my unit tests, the ones defined
I am trying to divide an xts object which holds a number of time
How can return a subset of a FormCollection with key/values in tact for those
Is LINQ to Dataset subset of LINQ to EF or these two are independent?
I stubbed the subset billed? method subset.stub(:billed?).and_return(true) line_item has a delegate for billed? to

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.