0

I have a dataset which has hourly value measurements for three variables (val_1, val_2, val_3), across three years from 2010 to 2012

I'm trying to use lubridate and tidyverse to filter out the daily maximum value of this dataset

structure(list(Timestamp = c("2010-01-01 01:00:00", "2010-01-01 02:00:00", 
"2010-01-01 03:00:00", "2010-01-01 04:00:00", "2010-01-01 05:00:00", 
"2010-01-01 06:00:00"), val_1 = c(44L, 44L, 44L, 44L, 43L, 42L
), val_2 = c(100L, 96L, 93L, 89L, 89L, 83L), val_3 = c(0L, 0L, 
0L, 0L, 0L, 0L)), class = "data.frame", row.names = c("1", "2", 
"3", "4", "5", "6"))

            Timestamp   val_1    val_2       val_3 
1 2010-01-01 01:00:00      44      100           0 
2 2010-01-01 02:00:00      44       96           0 
3 2010-01-01 03:00:00      44       93           0 
4 2010-01-01 04:00:00      44       89           0 
5 2010-01-01 05:00:00      43       89           0 
6 2010-01-01 06:00:00      42       83           0 

I've been trying to get an output that shows this daily maximum value of val_1, but I just can't quite get it to output each individual daily maximum, rather it always just returns the max for the entire column

 data %>%
  group_by(Day = as.Date(Timestamp)) %>%
  summarise(max_value = max(val_1))

Does anyone know what I'm doing wrong?

1 Answers1

0
data %>%
group_by(Day = as.Date(Timestamp)) %>%
dplyr::summarise(max_value = max(val_1))

Solution: I needed to call the dplyr package within my piped code for the summarise function