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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:05:07+00:00 2026-05-20T05:05:07+00:00

I am completely new to gnuplot and am only trying this because I need

  • 0

I am completely new to gnuplot and am only trying this because I need to learn it. I have a values in three columns where the first represents the filename (date and time, one hour interval) and the remaining two columns represent two different entities Prop1 and Prop2.

Datetime             Prop1        Prop2

20110101_0000.txt     2            5
20110101_0100.txt     2            5
20110101_0200.txt     2            5
...
20110101_2300.txt     2            5
20110201_0000.txt     2            5
20110101_0100.txt     2            5
...
20110201_2300.txt     2            5
...

I need to aggregate the data by the hour of the day (the **_0100) which is the last four numeric digits. So, I want to create another column called hour which tells me the hour of the day. It means 0000 = 0h, 0100 = 1h, ...... 2200 = 22h etc.

I then want to get the sum of Prop1 and Prop2 for each hour, so in the end get something like.

Hour  Prop1   Prop2
0h     120     104
1h     230     160
...
10h    90      110
...
23h    100    200 

and the get a line plot of Prop1 and Prop2.

  • 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-20T05:05:07+00:00Added an answer on May 20, 2026 at 5:05 am

    A general solution with gsub :

    Data$Hour <- gsub(".+_(\\d+).txt","\\1",Data$Datetime)
    

    EDIT :

    You can use Data$Hour <- substr(Data$Hour,1,2) to get just the hour. As said in the comments, if you always have exactly the same structure in Datetime, you could use substr() immediately:

    Data$Hour <- substr(Data$Datetime,10,11)
    

    Then you can use aggregate, tapply, by, … whatever to do what you want. To sum both Prop1 and Prop2, you can use aggregate, eg:

    aggregate(Data[2:3],list(Data$Hour),sum)
    

    with the dataset :

    zz<-textConnection("Datetime             Prop1        Prop2
    20110101_0000.txt     2            5
    20110101_0100.txt     2            5
    20110101_0200.txt     2            5
    20110101_2300.txt     2            5
    20110201_0000.txt     2            5
    20110201_0100.txt     2            5
    20110201_0200.txt     2            5
    20110201_2300.txt     2            5")
    Data <- read.table(zz,header=T,as.is=T)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Completely new to Objective-C, trying to find out when I need to alloc and
I am completely new to C and need help with this badly. Im reading
First off I am completely new to Javascript but I have some HTML/CSS experience.
Completely new to most of this stuff, but basically Im playing around with the
Completely new to java and I have been playing around with regex in a
I am completely new to HTML5 and have been reading about it for the
I'm completely new to javascript, but I'm trying to create a beta form for
I'm completely new with IFC files. For my company I need to read IFC
I am completely new to Xcode and iOS developing in general. Basically I have
I am completely new to SSIS, in fact the below wold be my first

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.