Skip to contents

Filter dataframe for data of one specified year only.

Usage

get_data_for_year(power_data, selected_year)

Arguments

power_data

data frame with timestamp columns.

selected_year

year for which to return data.

Value

A data frame with data only for the selected year.

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("2001-01-02 01:00:00", tz = "UTC"),
    as.POSIXct("2002-02-01 02:00:00", tz = "UTC"),
    as.POSIXct("2003-02-02 02:00:00", tz = "UTC")
  ),
  total_input = c(1.0, 2.0, 3.0, 4.0),
  total_output = c(4.0, 3.0, 2.0, 1.0)
)
get_data_for_year(power_data, 2002)
#>             timestamp total_input total_output
#> 1 2002-02-01 02:00:00           3            2