Analyze time series data split by date within years
Usage
anlz_splitdata(
df,
date_split,
date_col = "date",
value_col = "value",
stats = list(avg = mean)
)
Examples
# Create sample data
data <- data.frame(
date = seq.Date(as.Date("2010-01-01"), as.Date("2020-12-31"), by = "month"),
value = rnorm(132, mean = 10, sd = 2))
# Basic analysis with default statistics
split_date <- as.Date("2015-06-15")
anlz_splitdata(data, split_date, "date", "value")
#> # A tibble: 12 × 3
#> year period avg
#> <dbl> <ord> <dbl>
#> 1 2010 before 9.39
#> 2 2011 before 9.33
#> 3 2012 before 9.73
#> 4 2013 before 10.2
#> 5 2014 before 10.4
#> 6 2015 before 9.99
#> 7 2016 after 10.5
#> 8 2017 after 10.4
#> 9 2018 after 10.8
#> 10 2019 after 9.00
#> 11 2020 after 11.2
#> 12 2021 after 9.90