Skip to contents

Aggregates and reshapes the data by hour, returning it in a long format.

Usage

get_hourly_data_long(power_data)

Arguments

power_data

data frame with timestamp, INPUT, and OUTPUT columns.

Value

A data frame with hourly total_input and total_output values.

Examples

# Example using a small sample data frame
power_data <- data.frame(
  timestamp = c(
    as.POSIXct("2000-01-01 01:00:00", tz = "UTC"),
    as.POSIXct("2000-01-02 01:00:00", tz = "UTC"),
    as.POSIXct("2000-02-01 02:00:00", tz = "UTC"),
    as.POSIXct("2000-02-02 02:00:00", tz = "UTC")
  ),
  INPUT = c(1.0, 2.0, 3.0, 4.0),
  OUTPUT = c(4.0, 3.0, 2.0, 1.0)
)
get_hourly_data_long(power_data)
#> # A tibble: 4 × 3
#>   hour  type         value
#>   <chr> <chr>        <dbl>
#> 1 01    total_input      3
#> 2 01    total_output     7
#> 3 02    total_input      7
#> 4 02    total_output     3