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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:34:06+00:00 2026-06-13T07:34:06+00:00

My questions is closely related to the one asked here: Pull Return from first

  • 0

My questions is closely related to the one asked here: Pull Return from first business day of the month from XTS object using R.

Instead of extracting the first day of each month, I want to extract, say the 10th data point of each month. How can I do this?

  • 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-13T07:34:07+00:00Added an answer on June 13, 2026 at 7:34 am

    Using the same example data from the question you’ve linked to, you can do some basic subsetting.

    Here’s the sample data:

    library(xts)
    data(sample_matrix)
    x <- as.xts(sample_matrix)
    

    Here’s the subsetting:

    x[format(index(x), "%d") == "10"]
    #                Open     High      Low    Close
    # 2007-01-10 49.91228 50.13053 49.91228 49.97246
    # 2007-02-10 50.68923 50.72696 50.60707 50.69562
    # 2007-03-10 49.79370 49.88984 49.70385 49.88698
    # 2007-04-10 49.55704 49.78776 49.55704 49.76984
    # 2007-05-10 48.83479 48.84549 48.38001 48.38001
    # 2007-06-10 47.74899 47.74899 47.28685 47.28685
    

    Is this what you were looking for?


    Using %in% would give you some more flexibility. For instance, if you wanted the tenth, eleventh, and twelfth days of each month, you could use x[format(index(x), "%d") %in% c("10", "11", "12")] instead.


    Update

    If, as you have in your update, you want to extract the tenth data point, just use an anonymous function as follows:

    do.call(rbind, lapply(split(x, "months"), function(x) x[10]))
    #                Open     High      Low    Close
    # 2007-01-11 49.88529 50.23910 49.88529 50.23910
    # 2007-02-10 50.68923 50.72696 50.60707 50.69562
    # 2007-03-10 49.79370 49.88984 49.70385 49.88698
    # 2007-04-10 49.55704 49.78776 49.55704 49.76984
    # 2007-05-10 48.83479 48.84549 48.38001 48.38001
    # 2007-06-10 47.74899 47.74899 47.28685 47.28685
    

    Note that the first row is the eleventh day of the month, because the data actually starts on January 2, 2007.

    x[1, ]
    #                Open     High      Low    Close
    # 2007-01-02 50.03978 50.11778 49.95041 50.11778
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two closely related questions: First, how can the Haskell's Arrow class be
The question is closely related to my past question here, but it is not
This is closely related to anothewr question I have asked but since this is
This is closely related to a previous question i asked. I have a many-to-many
I suppose this is two very closely related questions: Everyone says to start with
For functions with closely related formal parameters, such as def add_two_numbers(n1, n2): return n1
Two closely-related data structures are the suffix tree and suffix array. From what I've
This question is closely related to this one but i think is more general.
This question is closely related to Jquery - Send only some value from a
Questions exactly like this have been asked before, i've read them all and tried

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.