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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:13:01+00:00 2026-05-12T09:13:01+00:00

I have some data in CSV like: Timestamp, Count 2009-07-20 16:30:45, 10 2009-07-20 16:30:45,

  • 0

I have some data in CSV like:

"Timestamp", "Count"
"2009-07-20 16:30:45", 10
"2009-07-20 16:30:45", 15
"2009-07-20 16:30:46", 8
"2009-07-20 16:30:46", 6
"2009-07-20 16:30:46", 8
"2009-07-20 16:30:47", 20

I can read it into R using read.cvs. I’d like to plot:

  1. Number of entries per second, so:
    "2009-07-20 16:30:45", 2
    "2009-07-20 16:30:46", 3
    "2009-07-20 16:30:47", 1
    
  2. Average value per second:
    "2009-07-20 16:30:45", 12.5
    "2009-07-20 16:30:46", 7.333
    "2009-07-20 16:30:47", 20
    
  3. Same as 1 & 2 but then by Minute and then by Hour.

Is there some way to do this (collect by second/min/etc & plot) in R?

  • 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-12T09:13:01+00:00Added an answer on May 12, 2026 at 9:13 am

    Read your data, and convert it into a zoo object:

    R> X <- read.csv("/tmp/so.csv")
    R> X <- zoo(X$Count, order.by=as.POSIXct(as.character(X[,1])))
    

    Note that this will show warnings because of non-unique timestamps.

    Task 1 using aggregate with length to count:

    R> aggregate(X, force, length)
    2009-07-20 16:30:45 2009-07-20 16:30:46 2009-07-20 16:30:47 
                      2                   3                   1 
    

    Task 2 using aggregate:

    R> aggregate(X, force, mean)
    2009-07-20 16:30:45 2009-07-20 16:30:46 2009-07-20 16:30:47 
                 12.500               7.333              20.000 
    

    Task 3 can be done the same way by aggregating up to higher-order indices. You can call plot on the result from aggregate:

    plot(aggregate(X, force, mean))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some questions about importing data from Excel/CSV File into SQL Server. Let
I have some CSV data files that I want to import into mySQL. I
I have some hospital data in a dataframe, read in from a csv. I
I have a data file in CSV format that has the some data like
I'm trying to read some CSV-format financial tick data (source: HISTDATA_COM_ASCII_EURUSD_T_201209.zip ) into a
I have some imported csv data that I have turned into an xts object.
I export some of my db into a csv using PhpExcel. Because I have
I have some data from log files and would like to group entries by
I have some data that is stored in a TIMESTAMP(6) WITH TIMEZONE column in
I have some one-many normalized data that looks like this. a | x a

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.