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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:06:43+00:00 2026-06-01T12:06:43+00:00

I have an irregular time series contained in xts and separate time index vector

  • 0

I have an irregular time series contained in xts and separate time index vector (endpoints).
I want to calculate statistics for every index point based on preceding 5 seconds for every endpoint. So, starting point should be 5 seconds before every endpoint. These periods may overlap.

I cannot find any function from *apply family doing that job. How can I do that? Should I manually write loop for it?

Here is my humble illustration where black is xts data and red are endpoints. I want to have a result of a function for every red point calculated on all black points in 5-seconds interval.

overlapping intervals

  • 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-01T12:06:44+00:00Added an answer on June 1, 2026 at 12:06 pm

    There isn’t a ready-made function to do this, but it’s fairly easy to write your own.

    # Example data
    library(xts)
    data(sample_matrix)
    x <- as.xts(sample_matrix)
    # Example function
    # Calculate the mean of the last 5 days of each month, returning
    # an xts object indexed at the endpoint
    myFunction <- function(i, y) xts(t(colMeans(y[(i-4):i,])), index(y)[i])
    # Use lapply to call your function at each endpoint
    # (removing first endpoint, since it equals zero) 
    do.call(rbind, lapply(endpoints(x, 'months')[-1], FUN=myFunction, y=x))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an irregular time series and am using xts 's endpoints to get
I have an irregular time series ( xts in R ) that I want
If I have some multivariate irregular time series, such as zoo or xts objects
I have a time series of temperature profiles that I want to interpolate, I
I need to add two irregular time series (covering business days). I have two
I have an irregular time series that I'm working with that I'd like to
I have a ListView that gets updated frequently, at irregular intervals. I want it
EDIT (for clarification): I have a vector image with a simple contour, an irregular
I have a whole bunch of data.frames with irregular time spacing. I would like
I have an irregular mesh which is described by two variables - a faces

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.