For loop to sum non-equal increments of data in excel

Hi everyone! I am new to R and need some help!

I am trying to make a for loop to sum precipitation values in one day. However, some days the increments of data are not equal (some days have data every 15 minutes other days have data every 10 minutes). I have converted the dates into a floating number in my excel file to help, but I do not know how to write a for loop that will read these numbers in excel.

For example, for data every 15 minutes I would write for(k in 1:96) to sum data that day. But some days have data every 15 minutes, while others is every 10 minutes, so this loop will not properly sum the days.

Are you working in Excel or in R? If you're working in R, you can group by the date (the number of values for a given date won't actually matter), and sum them by group.

I am working in R! How would you group data? I have never done that before.

In the tidyverse, you'd do this with the group_by() and summarise() functions. If you're completely new to this, I really recommend taking a look at this chapter in R for Data Science:

Okay, thank you so much!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.