[R] climate data-set; aggregate date (day)

Thierry Onkelinx thierry.onkelinx at inbo.be
Thu Aug 3 12:54:02 CEST 2017


library(dplyr)
library(lubridate)
data %>%
group_by(floor_date(Timestamp, unit = "day")) %>%
summarise(rain = sum(Rain_mm_tot))

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2017-08-03 12:31 GMT+02:00 T Wan <twan op web.de>:

> 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 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
> Torben
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help op r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]



More information about the R-help mailing list