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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:49:13+00:00 2026-05-29T07:49:13+00:00

The list below is sum of data corresponding to each month in a time

  • 0

The list below is sum of data corresponding to each month in a time series using the following snippet:

aggregate(data, by=list(Year=format(DateTime, "%Y"), Month=format(DateTime, "%m")), sum, na.rm=TRUE)

Year Month        x
1   1981    01 62426.43
2   1982    01 70328.87
3   1983    01 67516.34
4   1984    01 64454.00
5   1985    01 78801.46
6   1986    01 73865.18
7   1987    01 64224.96
8   1988    01 72362.39
9   1981    02 74835.16
10  1982    02 75275.58
11  1983    02 67457.39
12  1984    02 64981.99
13  1985    02 56490.10
14  1986    02 62759.89
15  1987    02 65144.44
16  1988    02 67704.67

This part is easy…but I am tripping up on trying to get an average of all the monthly sums for each month (i.e. one average of the sums for each month)
If I do the following:

aggregate(data, by=list(Month=format(DateTime, "%m")), sum, na.rm=TRUE)

I just get a sum of all months in the time series, which is what i dont want. Can i achieve the desired result in one aggregate statement, or do I need more code…Any help would be appreciated.

  • 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-29T07:49:14+00:00Added an answer on May 29, 2026 at 7:49 am

    You can do it with 2 aggregate statements:

    aggregate(x~Month, aggregate(data, by=list(Year=format(DateTime, "%Y"), Month=format(DateTime, "%m")), sum, na.rm=TRUE), mean)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the below query to list the number of transactions by month.
In below data list represents set of question's and answer, How to check whether
I have the following code below for list into master page <div id=header> <ul>
I wanted to generate a list view using below code. But after running this
Im getting the following error for the piece of code below : expression list
I have a list (see below) contained in a window. The window's DataContext has
I want to do the below list iteration in django templates: foo = ['foo',
I have a Generic List as below public static readonly List<Customer> Customers = new
When I click on the list-item below (li) I change the id of it
I'm appending to a list then throwing that list into a function below: List<ItemBean>

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.