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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:20:30+00:00 2026-05-27T09:20:30+00:00

I’m using R to do some time series analysis using zoo and chron. I’ve

  • 0

I’m using R to do some time series analysis using zoo and chron. I’ve got a zoo object with lots of data in it, and need to be able to use the window function to subset the data to just one days worth, then the next days worth, then the next etc.

I’ve tried to find the easiest way of creating an array with the date of each day in a certain period in it and have come up with the following:

orig = c(month=1, day=1, year=2005)
dates <- chron(1:1825, origin=orig, out.format=c(dates="d/m/y", times="h:m"))

This uses the Julian day notation, and has 1825 days (365*5 – so five years), starting with the first day of my date period. I then try and do a for loop using each of the elements of this array:

for (date in dates)
{
  s = chron(date, "00:00:00", origin=orig)
  e = chron(date, "23:59:59", origin=orig)

  aeronet_day = window(aeronet, start=s, end=e)
}

However, this gives me a warning saying that I’m using different origins for the aeronet zoo object and the s and e variables, and it doesn’t select any data.

Is there a better way to do this? Or a way to fix this? Basically what I want is to run a for loop where in the loop I can use the aeronet_day = window(aeronet, start=s, end=e) code to produce a zoo object containing the data for one day (eg. 1st May 2005 from 00:00:00 to 23:59:59.

  • 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-27T09:20:30+00:00Added an answer on May 27, 2026 at 9:20 am

    Suppose we have this data:

    # create test data
    library(zoo)
    library(chron)
    z <- zooreg(1:30, start = chron("2000-01-01"), freq = 2)
    

    1) aggregate
    The R aggregate function has a zoo method. The second argument is what we aggregate by. If it is a function it is applied to the index of the zoo object. e.g. here we calculate the mean for each date:

    z.ag <- aggregate(z, as.Date, mean)
    

    We can replace mean with a more complex function if we wish.

    2) split. The R split function has a zoo method. If we really do want to split z by date then we can do this. Here z.split.list is a list, each of whose components contains the zoo object for one date.

    z.split.list <- split(z, as.Date(time(z)))
    

    Now (a) sapply or (b) lapply over that list or (c) use the following (replacing print(zc) with whatever processing is desired). Here zc is a component of the list, i.e. it is the zoo object formed by just taking a particular date:

    for(zc in z.split.list) print(zc)
    

    Note that as.Date(time(z)) is a vector with the dates corresponding to the elements of z.

    EDIT:

    Various minor elaborations.

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

Sidebar

Related Questions

i got an object with contents of html markup in it, for example: string
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.