A running sum for daily data that resets when month turns - r

I have a 2 column table (tibble), made up of a date object and a numeric variable. There is maximum one entry per day but not every day has an entry (ie date is a natural primary key). I am attempting to do a running sum of the numeric column along with dates but with the running sum resetting when the month turns (the data is sorted by ascending date). I have replicated what I want to get as a result below.
Date score monthly.running.sum
10/2/2019 7 7
10/9/2019 6 13
10/16/2019 12 25
10/23/2019 2 27
10/30/2019 13 40
11/6/2019 2 2
11/13/2019 4 6
11/20/2019 15 21
11/27/2019 16 37
12/4/2019 4 4
12/11/2019 24 28
12/18/2019 28 56
12/25/2019 8 64
1/1/2020 1 1
1/8/2020 15 16
1/15/2020 9 25
1/22/2020 8 33
It looks like the package "runner" is possibly suited to this but I don't really understand how to instruct it. I know I could use a join operation plus a group_by using dplyr to do this, but the data set is very very large and doing so would be wildly inefficient. i could also manually iterate through the list with a loop, but that also seems inelegant. last option i can think of is selecting out a unique vector of yearmon objects and then cutting the original list into many shorter lists and running a plain cumsum on it, but that also feels unoptimal. I am sure this is not the first time someone has to do this, and given how many tools there is in the tidyverse to do things, I think I just need help finding the right one. The reason I am looking for a tool instead of using one of the methods I described above (which would take less time than writing this post) is because this code needs to be very very readable by an audience that is less comfortable with code.

We can also use data.table
library(data.table)
setDT(df)[, Date := as.IDate(Date, "%m/%d/%Y")
][, monthly.running.sum := cumsum(score),format(Date, "%Y-%m")][]
# Date score monthly.running.sum
# 1: 2019-10-02 7 7
# 2: 2019-10-09 6 13
# 3: 2019-10-16 12 25
# 4: 2019-10-23 2 27
# 5: 2019-10-30 13 40
# 6: 2019-11-06 2 2
# 7: 2019-11-13 4 6
# 8: 2019-11-20 15 21
# 9: 2019-11-27 16 37
#10: 2019-12-04 4 4
#11: 2019-12-11 24 28
#12: 2019-12-18 28 56
#13: 2019-12-25 8 64
#14: 2020-01-01 1 1
#15: 2020-01-08 15 16
#16: 2020-01-15 9 25
#17: 2020-01-22 8 33
data
df <- structure(list(Date = c("10/2/2019", "10/9/2019", "10/16/2019",
"10/23/2019", "10/30/2019", "11/6/2019", "11/13/2019", "11/20/2019",
"11/27/2019", "12/4/2019", "12/11/2019", "12/18/2019", "12/25/2019",
"1/1/2020", "1/8/2020", "1/15/2020", "1/22/2020"), score = c(7L,
6L, 12L, 2L, 13L, 2L, 4L, 15L, 16L, 4L, 24L, 28L, 8L, 1L, 15L,
9L, 8L)), row.names = c(NA, -17L), class = "data.frame")

Using lubridate, you can extract month and year values from the date, group_by those values and them perform the cumulative sum as follow:
library(lubridate)
library(dplyr)
df %>% mutate(Month = month(mdy(Date)),
Year = year(mdy(Date))) %>%
group_by(Month, Year) %>%
mutate(SUM = cumsum(score))
# A tibble: 17 x 6
# Groups: Month, Year [4]
Date score monthly.running.sum Month Year SUM
<chr> <int> <int> <int> <int> <int>
1 10/2/2019 7 7 10 2019 7
2 10/9/2019 6 13 10 2019 13
3 10/16/2019 12 25 10 2019 25
4 10/23/2019 2 27 10 2019 27
5 10/30/2019 13 40 10 2019 40
6 11/6/2019 2 2 11 2019 2
7 11/13/2019 4 6 11 2019 6
8 11/20/2019 15 21 11 2019 21
9 11/27/2019 16 37 11 2019 37
10 12/4/2019 4 4 12 2019 4
11 12/11/2019 24 28 12 2019 28
12 12/18/2019 28 56 12 2019 56
13 12/25/2019 8 64 12 2019 64
14 1/1/2020 1 1 1 2020 1
15 1/8/2020 15 16 1 2020 16
16 1/15/2020 9 25 1 2020 25
17 1/22/2020 8 33 1 2020 33
An alternative will be to use floor_date function in order ot convert each date as the first day of each month and the calculate the cumulative sum:
library(lubridate)
library(dplyr)
df %>% mutate(Floor = floor_date(mdy(Date), unit = "month")) %>%
group_by(Floor) %>%
mutate(SUM = cumsum(score))
# A tibble: 17 x 5
# Groups: Floor [4]
Date score monthly.running.sum Floor SUM
<chr> <int> <int> <date> <int>
1 10/2/2019 7 7 2019-10-01 7
2 10/9/2019 6 13 2019-10-01 13
3 10/16/2019 12 25 2019-10-01 25
4 10/23/2019 2 27 2019-10-01 27
5 10/30/2019 13 40 2019-10-01 40
6 11/6/2019 2 2 2019-11-01 2
7 11/13/2019 4 6 2019-11-01 6
8 11/20/2019 15 21 2019-11-01 21
9 11/27/2019 16 37 2019-11-01 37
10 12/4/2019 4 4 2019-12-01 4
11 12/11/2019 24 28 2019-12-01 28
12 12/18/2019 28 56 2019-12-01 56
13 12/25/2019 8 64 2019-12-01 64
14 1/1/2020 1 1 2020-01-01 1
15 1/8/2020 15 16 2020-01-01 16
16 1/15/2020 9 25 2020-01-01 25
17 1/22/2020 8 33 2020-01-01 33

A base R alternative :
df$Date <- as.Date(df$Date, "%m/%d/%Y")
df$monthly.running.sum <- with(df, ave(score, format(Date, "%Y-%m"),FUN = cumsum))
df
# Date score monthly.running.sum
#1 2019-10-02 7 7
#2 2019-10-09 6 13
#3 2019-10-16 12 25
#4 2019-10-23 2 27
#5 2019-10-30 13 40
#6 2019-11-06 2 2
#7 2019-11-13 4 6
#8 2019-11-20 15 21
#9 2019-11-27 16 37
#10 2019-12-04 4 4
#11 2019-12-11 24 28
#12 2019-12-18 28 56
#13 2019-12-25 8 64
#14 2020-01-01 1 1
#15 2020-01-08 15 16
#16 2020-01-15 9 25
#17 2020-01-22 8 33

The yearmon class represents year/month objects so just convert the dates to yearmon and accumulate by them using this one-liner:
library(zoo)
transform(DF, run.sum = ave(score, as.yearmon(Date, "%m/%d/%Y"), FUN = cumsum))
giving:
Date score run.sum
1 10/2/2019 7 7
2 10/9/2019 6 13
3 10/16/2019 12 25
4 10/23/2019 2 27
5 10/30/2019 13 40
6 11/6/2019 2 2
7 11/13/2019 4 6
8 11/20/2019 15 21
9 11/27/2019 16 37
10 12/4/2019 4 4
11 12/11/2019 24 28
12 12/18/2019 28 56
13 12/25/2019 8 64
14 1/1/2020 1 1
15 1/8/2020 15 16
16 1/15/2020 9 25
17 1/22/2020 8 33

Related

How to calculate the number of months from the initial date for each individual

This is a representation of my dataset
ID<-c(rep(1,10),rep(2,8))
year<-c(2007,2007,2007,2008,2008,2009,2010,2009,2010,2011,
2008,2008,2009,2010,2009,2010,2011,2011)
month<-c(2,7,12,4,11,6,11,1,9,4,3,6,7,4,9,11,2,8)
mydata<-data.frame(ID,year,month)
I want to calculate for each individual the number of months from the initial date. I am using two variables: year and month.
I firstly order years and months:
mydata2<-mydata%>%group_by(ID,year)%>%arrange(year,month,.by_group=T)
Then I created the variable date considering that the day begin with 01:
mydata2$date<-paste("01",mydata2$month,mydata2$year,sep = "-")
then I used lubridate to change this variable in date format
mydata2$date<-dmy(mydata2$date)
But after this, I really don't know what to do, in order to have such a dataset (preferably using dplyr code) below:
ID year month date dif_from_init
1 1 2007 2 01-2-2007 0
2 1 2007 7 01-7-2007 5
3 1 2007 12 01-12-2007 10
4 1 2008 4 01-4-2008 14
5 1 2008 11 01-11-2008 21
6 1 2009 1 01-1-2009 23
7 1 2009 6 01-6-2009 28
8 1 2010 9 01-9-2010 43
9 1 2010 11 01-11-2010 45
10 1 2011 4 01-4-2011 50
11 2 2008 3 01-3-2008 0
12 2 2008 6 01-6-2008 3
13 2 2009 7 01-7-2009 16
14 2 2009 9 01-9-2009 18
15 2 2010 4 01-4-2010 25
16 2 2010 11 01-11-2010 32
17 2 2011 2 01-2-2011 35
18 2 2011 8 01-8-2011 41
One way could be:
mydata %>%
group_by(ID) %>%
mutate(date = as.Date(sprintf('%d-%d-01',year, month)),
diff = as.numeric(round((date - date[1])/365*12)))
# A tibble: 18 x 5
# Groups: ID [2]
ID year month date diff
<dbl> <dbl> <dbl> <date> <dbl>
1 1 2007 2 2007-02-01 0
2 1 2007 7 2007-07-01 5
3 1 2007 12 2007-12-01 10
4 1 2008 4 2008-04-01 14
5 1 2008 11 2008-11-01 21
6 1 2009 6 2009-06-01 28
7 1 2010 11 2010-11-01 45
8 1 2009 1 2009-01-01 23
9 1 2010 9 2010-09-01 43
10 1 2011 4 2011-04-01 50
11 2 2008 3 2008-03-01 0
12 2 2008 6 2008-06-01 3
13 2 2009 7 2009-07-01 16
14 2 2010 4 2010-04-01 25
15 2 2009 9 2009-09-01 18
16 2 2010 11 2010-11-01 32
17 2 2011 2 2011-02-01 35
18 2 2011 8 2011-08-01 41

how to determine season dry or rainy in temporal analysis using R?

I have the data temporal of temperature, i would like determinate if date be to season dry or rainy.
In my coutry the season dry start in May up to October, and season rainy start in November up to April.
Would be possible create a column with this information in package dplyr ou other?
my data-frame in:
sample_station <-c('A','A','A','A','A','A','A','A','A','A','A','B','B','B','B','B','B','B','B','B','B','C','C','C','C','C','C','C','C','C','C','A','B','C','A','B','C')
Date_dmy <-c('01/01/2000','08/08/2000','16/03/2001','22/09/2001','01/06/2002','05/01/2002','26/01/2002','16/02/2002','09/03/2002','30/03/2002','20/04/2002','04/01/2000','11/08/2000','19/03/2001','25/09/2001','04/06/2002','08/01/2002','29/01/2002','19/02/2002','12/03/2002','13/09/2001','08/01/2000','15/08/2000','23/03/2001','29/09/2001','08/06/2002','12/01/2002','02/02/2002','23/02/2002','16/03/2002','06/04/2002','01/02/2000','01/02/2000','01/02/2000','02/11/2001','02/11/2001','02/11/2001')
Temperature <-c(17,20,24,19,17,19,23,26,19,19,21,15,23,18,22,22,23,18,19,26,21,22,23,27,19,19,21,23,24,25,26,29,30,21,25,24,23)
df<-data.frame(sample_station, Date_dmy, Temperature)
One option is to extract the month after converting to Date class, create a condition in case_when to return 'dry', 'rainy' based on the values of 'Month' column
library(dplyr)
library(lubridate)
df <- df %>%
mutate(Month = month(dmy(Date_dmy)),
categ = case_when(Month %in% 5:10 ~ 'dry', TRUE ~ 'rainy'))
Similar to akrun's solution but with ifelse:
library(dplyr)
library(lubridate)
df <- df %>%
mutate(Month = month(dmy(Date_dmy)),
categ = ifelse(Month %in% 5:10,'dry','rainy'))
Output:
sample_station Date_dmy Temperature Month categ
1 A 01/01/2000 17 1 rainy
2 A 08/08/2000 20 8 dry
3 A 16/03/2001 24 3 rainy
4 A 22/09/2001 19 9 dry
5 A 01/06/2002 17 6 dry
6 A 05/01/2002 19 1 rainy
7 A 26/01/2002 23 1 rainy
8 A 16/02/2002 26 2 rainy
9 A 09/03/2002 19 3 rainy
10 A 30/03/2002 19 3 rainy
11 A 20/04/2002 21 4 rainy
12 B 04/01/2000 15 1 rainy
13 B 11/08/2000 23 8 dry
14 B 19/03/2001 18 3 rainy
15 B 25/09/2001 22 9 dry
16 B 04/06/2002 22 6 dry
17 B 08/01/2002 23 1 rainy
18 B 29/01/2002 18 1 rainy
19 B 19/02/2002 19 2 rainy
20 B 12/03/2002 26 3 rainy
21 B 13/09/2001 21 9 dry
22 C 08/01/2000 22 1 rainy
23 C 15/08/2000 23 8 dry
24 C 23/03/2001 27 3 rainy
25 C 29/09/2001 19 9 dry
26 C 08/06/2002 19 6 dry
27 C 12/01/2002 21 1 rainy
28 C 02/02/2002 23 2 rainy
29 C 23/02/2002 24 2 rainy
30 C 16/03/2002 25 3 rainy
31 C 06/04/2002 26 4 rainy
32 A 01/02/2000 29 2 rainy
33 B 01/02/2000 30 2 rainy
34 C 01/02/2000 21 2 rainy
35 A 02/11/2001 25 11 rainy
36 B 02/11/2001 24 11 rainy
37 C 02/11/2001 23 11 rainy

Rolling lowest mean and stdev of n consecutive minutes of each time period

New R user here looking for guidance. I am working with a 15-minute data set and looking to parse out the following by one variable (buildings in my case) for each day of the year:
(1) lowest mean of "value" for n consecutive rows (preferably 2 or 3 hours worth)
(2) standard deviation of the same period
Sample df:
variable year month day hr min date value
building_a 2018 6 2 0 0 6/2/2018 19
building_a 2018 6 2 0 15 6/2/2018 19
building_a 2018 6 2 0 30 6/2/2018 19
building_a 2018 6 2 0 45 6/2/2018 17
building_a 2018 6 2 1 0 6/2/2018 17
building_a 2018 6 2 1 15 6/2/2018 15
building_a 2018 6 2 1 30 6/2/2018 15
building_a 2018 6 2 1 45 6/2/2018 14
building_a 2018 6 2 2 0 6/2/2018 14
building_a 2018 6 2 2 15 6/2/2018 13
building_a 2018 6 2 2 30 6/2/2018 13
building_a 2018 6 2 2 45 6/2/2018 13
building_a 2018 6 2 3 0 6/2/2018 12
building_a 2018 6 2 3 15 6/2/2018 14
building_a 2018 6 2 3 30 6/2/2018 13
building_a 2018 6 2 3 45 6/2/2018 13
building_b 2018 6 2 0 0 6/2/2018 37
building_b 2018 6 2 0 15 6/2/2018 41
building_b 2018 6 2 0 30 6/2/2018 38
building_b 2018 6 2 0 45 6/2/2018 39
building_b 2018 6 2 1 0 6/2/2018 37
building_b 2018 6 2 1 15 6/2/2018 36
building_b 2018 6 2 1 30 6/2/2018 34
building_b 2018 6 2 1 45 6/2/2018 34
building_b 2018 6 2 2 0 6/2/2018 35
building_b 2018 6 2 2 15 6/2/2018 35
building_b 2018 6 2 2 30 6/2/2018 29
building_b 2018 6 2 2 45 6/2/2018 32
building_b 2018 6 2 3 0 6/2/2018 30
building_b 2018 6 2 3 15 6/2/2018 33
building_b 2018 6 2 3 30 6/2/2018 30
building_b 2018 6 2 3 45 6/2/2018 32
I've been able to perform this for one-hour segments using the following approach, but cannot figure out how to adapt this to a larger window (e.g., lowest 135 minute mean instead of 60 min).
tmp <- aggregate(value~variable+date+hour, df,
function(x)
c(mean = mean(x), sd = sd(x)))
tmp2 <- do.call("data.frame",tmp)
tmp2$value.mean <- as.numeric(tmp2$value.mean)
tmp2$value.sd <- as.numeric(tmp2$value.sd)
tmp2_flat <- tmp2 %>%
group_by(variable, date) %>%
filter(value.mean == min(value.mean)) %>%
arrange(variable, date, value.sd) %>%
slice(1)
Thank you in advance for any advice
I played a little around and this is what I came up with:
UPDATE: The last answer wasn't very practicable. There was no feedback but I'm changing it nevertheless.
library(zoo)
library(dplyr)
df %>%
group_by(variable, date) %>%
mutate(minimum = rollapply(value, width = 4, FUN = mean, fill = NA, align = "right"),
sd = rollapply(value, width = 4, FUN = sd, fill = NA, align = "right")) %>%
slice(which.min(minimum))
# A tibble: 2 x 10
# Groups: variable, date [2]
variable year month day hr min date value minimum sd
<fct> <int> <int> <int> <int> <int> <fct> <int> <dbl> <dbl>
1 building_a 2018 6 2 3 0 6/2/2018 12 12.8 0.5
2 building_b 2018 6 2 2 30 6/2/2018 29 33.2 2.87
The idea remains the same however. In the rollapply() function one can specifiy the n of consecutive rows via as width= argument. 4 means in this case 4 * 15 minutes = 1 hour, but can be any number of quarter hours.
And it calculates a "moving average" of valueat each row by looking back width rows.
That should do it I hope.

Conditional aggregation by regarding missing data in R

I am trying to aggregate hourly data to daily data in R. The problem is missing values. I want to consider a threshold for the number of missing values before the aggregation. If the number of missing values is more than two in the given day, DO NOT compute the daily average and fill that day with NA.
My dummy data are daily data for the first day of 2005.
day hour amount amount2
1 2005-01-01 0 1 1
2 2005-01-01 1 2 NA
3 2005-01-01 2 4 4
4 2005-01-01 3 5 5
5 2005-01-01 4 11 NA
6 2005-01-01 5 4 NA
7 2005-01-01 6 NA NA
8 2005-01-01 7 2 2
9 2005-01-01 8 4 4
10 2005-01-01 9 2 2
11 2005-01-01 10 4 20
12 2005-01-01 11 12 12
13 2005-01-01 12 13 13
14 2005-01-01 13 7 7
15 2005-01-01 14 4 4
16 2005-01-01 15 12 12
17 2005-01-01 16 4 4
18 2005-01-01 17 12 12
19 2005-01-01 18 5 5
20 2005-01-01 19 11 11
21 2005-01-01 20 4 4
22 2005-01-01 21 12 12
23 2005-01-01 22 13 13
24 2005-01-01 23 7 7
What I already got
agg
day amount amount2
1 2005-01-01 6.9 7.7
what I want to have
agg
day amount amount2
1 2005-01-01 6.9 NA
Because the number of missing values in the column amount2 is more than two, I want its daily average filled by NA (not 7.7) while it is calculated for the column amount (6.9).
I have used the function "aggregate" from "stats" library.
library(stats)
amount=(c(1,2,4,5,11,4,NA,2,4,2,4,12,13,7,4,12,4,12,5,11,4,12,13,7))
amount2=(c(1,NA,4,5,NA,NA,NA,2,4,2,20,12,13,7,4,12,4,12,5,11,4,12,13,7))
day=c("2005-01-01","2005-01-01","2005-01-01","2005-01-01","2005-01-01",
"2005-01-01","2005-01-01","2005-01-01","2005-01-01","2005-01-01",
"2005-01-01","2005-01-01","2005-01-01","2005-01-01","2005-01-01",
"2005-01-01","2005-01-01","2005-01-01","2005-01-01","2005-01-01",
"2005-01-01","2005-01-01","2005-01-01","2005-01-01")
hour=seq(0,23)
date=data.frame(day,hour)
dummy=cbind(date,amount,amount2)
agg <- aggregate(cbind(amount,amount2) ~ day, dummy, mean)

Subsets in subsets without looping in R

this is my starting data:
days <- c("01.01.2018","01.01.2018","01.01.2018","01.01.2018",
"02.01.2018","02.01.2018","02.01.2018","02.01.2018",
"03.01.2018","03.01.2018","03.01.2018","03.01.2018")
time <- c("00:00:00","08:00:00","12:00:00","16:00:00",
"00:00:00","08:00:00","12:00:00","16:00:00",
"00:00:00","08:00:00","12:00:00","16:00:00")
a <- c(10,12,11,14,
12,22,24,20,
11,8,13,16)
b <- c(18,22,26,21,
2,6,7,5,
27,31,29,26)
c <- a-b
d <- c(10,10,10,10,
20,20,20,20,
30,30,30,30)
df <- data.frame(days,time,a,b,c,d)
so df will come out as:
days time a b c d
1 01.01.2018 00:00:00 10 18 -8 10
2 01.01.2018 08:00:00 12 22 -10 10
3 01.01.2018 12:00:00 11 26 -15 10
4 01.01.2018 16:00:00 14 21 -7 10
5 02.01.2018 00:00:00 12 2 10 20
6 02.01.2018 08:00:00 22 6 16 20
7 02.01.2018 12:00:00 24 7 17 20
8 02.01.2018 16:00:00 20 5 15 20
9 03.01.2018 00:00:00 11 27 -16 30
10 03.01.2018 08:00:00 8 31 -23 30
11 03.01.2018 12:00:00 13 29 -16 30
12 03.01.2018 16:00:00 16 26 -10 30
in this dataframe i'd like to
for each day
find the first c value <-10
add the corresponding d values to ranges from the c value found before and the last c value of the day
this is what i've come up:
ndays <- unique(df$days)
for(i in 1:length(ndays)) {
if(!is.na(df[(df$days == ndays[i] & df$c <= -10),]$c[1]))
{
df[(df$days == ndays[i] & df$c <= -10),]$c <- df[(df$days == ndays[i] & df$c <= -10),]$c + df[(df$days == ndays[i] & df$c <= -10),]$d
}
}
Output will be:
days time a b c d
1 01.01.2018 00:00:00 10 18 -8 10
2 01.01.2018 08:00:00 12 22 0 10
3 01.01.2018 12:00:00 11 26 -5 10
4 01.01.2018 16:00:00 14 21 -7 10
5 02.01.2018 00:00:00 12 2 10 20
6 02.01.2018 08:00:00 22 6 16 20
7 02.01.2018 12:00:00 24 7 17 20
8 02.01.2018 16:00:00 20 5 15 20
9 03.01.2018 00:00:00 11 27 14 30
10 03.01.2018 08:00:00 8 31 7 30
11 03.01.2018 12:00:00 13 29 14 30
12 03.01.2018 16:00:00 16 26 20 30
Problem is, i'd like not to use a for loop since is slow, and is not adding d to the entire day. df$c[4] should be 3.
There is a solution using dplyr and lubridate. I'm not 100% sure to understand what you want to do, but I think it should help you to solve your problem.
days <- c("01.01.2018","01.01.2018","01.01.2018","01.01.2018",
"02.01.2018","02.01.2018","02.01.2018","02.01.2018",
"03.01.2018","03.01.2018","03.01.2018","03.01.2018")
time <- c("00:00:00","08:00:00","12:00:00","16:00:00",
"00:00:00","08:00:00","12:00:00","16:00:00",
"00:00:00","08:00:00","12:00:00","16:00:00")
a <- c(10,12,11,14,
12,22,24,20,
11,8,13,16)
b <- c(18,22,26,21,
2,6,7,5,
27,31,29,26)
c <- a-b
d <- c(10,10,10,10,
20,20,20,20,
30,30,30,30)
By creating a variable yday with lubridate functions, you can after group by this variable.You can use cumulative maximum cummax.
library(lubridate)
library(dplyr)
df %>%
mutate(yday = day(dmy(days))) %>%
mutate(is_below = c < -10) %>%
group_by(yday) %>%
mutate(to_add = cummax(is_below)) %>%
mutate(c = if_else(to_add == 1, true = c + d, false = c))
#> # A tibble: 12 x 9
#> # Groups: yday [3]
#> days time a b c d yday is_below to_add
#> <fctr> <fctr> <dbl> <dbl> <dbl> <dbl> <int> <lgl> <int>
#> 1 01.01.2018 00:00:00 10 18 -8 10 1 FALSE 0
#> 2 01.01.2018 08:00:00 12 22 -10 10 1 FALSE 0
#> 3 01.01.2018 12:00:00 11 26 -5 10 1 TRUE 1
#> 4 01.01.2018 16:00:00 14 21 3 10 1 FALSE 1
#> 5 02.01.2018 00:00:00 12 2 10 20 2 FALSE 0
#> 6 02.01.2018 08:00:00 22 6 16 20 2 FALSE 0
#> 7 02.01.2018 12:00:00 24 7 17 20 2 FALSE 0
#> 8 02.01.2018 16:00:00 20 5 15 20 2 FALSE 0
#> 9 03.01.2018 00:00:00 11 27 14 30 3 TRUE 1
#> 10 03.01.2018 08:00:00 8 31 7 30 3 TRUE 1
#> 11 03.01.2018 12:00:00 13 29 14 30 3 TRUE 1
#> 12 03.01.2018 16:00:00 16 26 20 30 3 FALSE 1

Resources