Climate data-set; aggregate Date (day)

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Climate data-set; aggregate Date (day)

This post has NOT been accepted by the mailing list yet.
Hi there,

I am trying to get the sum of rain per day.

That is what the data-set looks like:

Timestamp                        Rain_mm_Tot
2017-05-29 23:40:00         4.7999980
2017-05-29 23:50:00         1.2000000
2017-05-30 00:10:00         2.5800000
2017-05-30 00:20:00         1.2009600
2017-05-30 00:30:00         1.2000006
2017-05-30 00:40:00         2.5002480

First I tried to define the column as date format with:
data_date <-data[as.Date(data_date$Timestamp)<=as.Date("2017-06-15"),]

Then I tried to aggregate as followed:
data_date_sum <- aggregate(data_date$Timestamp, on = "days", k=1, by=list(cut(as.Date(data_date$Date))), FUN=sum)

R responds:
Error in as.Date.default(data_date$Date) :
  do not know how to convert 'data_date$Date' to class “Date”

I read serveral other post, but no other fits to my format.
Because I am a beginner I am open for completely new ideas to sum the daily rain also.

Thanks a lot and all the best