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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:50:35+00:00 2026-06-10T10:50:35+00:00

I have an xts object and I am trying to use period.apply with a

  • 0

I have an xts object and I am trying to use period.apply with a function that would return more than one value for each non-overlapping period. For example: I run a regression and would like to return the residuals for each non-overlapping period and thus my function returns all the dates from that period along with the residual at each particular date. It currently seems that xts does not support this behavior. Is this correct? Is there a work around?

> df <- data.frame(x=rnorm(31)+10, y=rnorm(31)+10)
> xts.data <- xts(df, order.by=as.Date(13514:(13544),origin="1970-01-01"))
> f <- function(d) {as.numeric(coredata(d[,"x"]))}
> period.apply(xts.data, INDEX=endpoints(xts.data,"weeks"), FUN=f)
Error in coredata.xts(x) : currently unsupported data type
  • 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-10T10:50:37+00:00Added an answer on June 10, 2026 at 10:50 am

    It just occurred to me that the problem is likely that each non-overlapping period doesn’t have the same number of observations, so there’s no way to easily create a matrix-like structure.

    Use something like this instead, and notice how each list element isn’t the same length:

    lapply(split(xts.data,"weeks"), f)
    

    To illustrate how period.apply can return more than one column per period:

    period.apply(xts.data, endpoints(xts.data,"weeks"), range)
    period.apply(xts.data, endpoints(xts.data,"weeks"), colMeans)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xts object (stock price time series) that is comprised of intraday
I have one main XTS object Data with ~1M rows spanning 22 days. I
i have an xts object which is about 2 mil rows. i am trying
I have an xts object that has intraday data: head(stocks[,1]) SMH.close 2009-01-02 09:31:00 17.66
I have some imported csv data that I have turned into an xts object.
I have a list of xts objects that are mutually exclusive days. I would
I have three vectors in an xts R object. Call them V1, V2, V3.
I have an xts sequence of stock trade events that I want to process
I have an XTS timeseries in R of the following format and am trying
I have been working on large datasets lately (more than 400 thousands lines). So

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.