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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:00:21+00:00 2026-06-15T22:00:21+00:00

This is my dataframe SHORT: ID IDaxis Y Date-Time Tdiff 1 1 5 2012-06-11

  • 0

This is my dataframe SHORT:

ID    IDaxis    Y   Date-Time       Tdiff  
1   1   5   2012-06-11 13:10:30 0.00    
1   1   10  2012-06-11 15:10:30 2.00    
1   1   20  2012-06-11 17:10:30 2.00    
1   3   15  2012-06-11 13:20:30 0.00    
1   3   30  2012-06-11 14:20:30 1.00    
1   3   45  2012-06-11 17:20:30 3.00    
1   6   9   2012-06-11 13:35:30 0.00        
1   6   15  2012-06-11 15:35:30 2.00    
1   6   30  2012-06-11 18:35:30 3.00    
3   2   8   2012-06-11 13:50:30 0.00  
3   2   14  2012-06-11 14:55:30 1.083   
3   2   20  2012-06-11 16:55:30 2.00    
3   2   30  2012-06-11 19:00:30 2.083   
3   5   10  2012-06-11 13:40:30 0.00    
3   5   15  2012-06-11 16:45:30 3.083   

ID – plant
IDaxis – plant leaf
Y – length of leaf
Date – Time – date and time of measurement
Tdiff – time(h) interval between measurement

I want to do (Example SHORT1):
1) sum up Tdiff for IDaxis in column SHORT$Ttot
2) calculate difference between row in Y for IDaxis in column SHORT$Ydiff
3) sum up Ydiff for IDaxis in column SHORT$Ytot

Example SHORT1:

enter image description here

Ydiff – length interval between measurement
Ytot – sum of length interval from measurement to measurement
Ttot – sum of time interval from measurement to measurement

I know how to calculate this for IDaxis if I split dataframe. My problem is that I have three dataframe each 700 ID, each have 100 IDaxis. I don’t know how to do it automaticly for whole dataframe. Thank You in advance.

  • 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-15T22:00:22+00:00Added an answer on June 15, 2026 at 10:00 pm

    You can use ave:

    SHORT$Ttot  <- ave(SHORT$Tdiff, SHORT$IDaxis, FUN = cumsum),
    SHORT$Ydiff <- ave(SHORT$Y,     SHORT$IDaxis, FUN = diff),
    SHORT$Ytot  <- ave(SHORT$Ydiff, SHORT$IDaxis, FUN = cumsum),
    

    (if you don’t like the repeated SHORT$, look at functions like transform.)

    You can also use the convenient plyr package:

    library(plyr)
    ddply(SHORT, "IDaxis", transform, Ttot  = cumsum(Tdiff),
                                      Ydiff = diff(Y),
                                      Ytot  = cumsum(Ydiff))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dataframe foo looking like this Date Return 1998-01-01 0.02 1998-01-02 0.04
I've got a data frame like this: id date amt 1 2012-05-03 10:33 32
Suppose I have a dataframe like this one: df <- data.frame (id = c(a,
I have a dataframe x with this values: x1 x2 x3 1 NA 4
I have a dataframe that looks like this: person n start end 1 sam
I have a dataframe with numeric entries like this one test <- data.frame(x =
I have a dataframe with distances df<-data.frame(site.x=c(A,A,A,B,B,C), site.y=c(B,C,D,C,D,D),Distance=c(67,57,64,60,67,60)) I need to convert this to
I have the data below saved as a pandas dataframe . With this data,
I've got this dataframe: Name Country Gender Age 1 John GB M 25 2
This is my first time trying Pandas. I think I have a reasonable use

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.