Function returns a time series of counts-by-location-and-date data, given length of baseline and test intervals, and an end date for the test-interval
Usage
generate_time_series_data(
data,
end_date = NULL,
locations = NULL,
baseline_length = 90,
test_length = 7,
guard = 0
)Arguments
- data
data frame with (at least) three columns: location, date, count
- end_date
date indicating end of test interval; if not provided the last date in `dt` will be used
- locations
a vector of locations to subset the table; if none provided then all locations will be used
- baseline_length
numeric (default=90) number of days in baseline interval
- test_length
numeric (default=7) number of days in test interval
- guard
numeric (default=0) number of days between baseline and test interval
Examples
generate_time_series_data(
data = example_count_data
)
#> date date_count
#> <IDat> <int>
#> 1: 2024-11-01 559
#> 2: 2024-11-02 608
#> 3: 2024-11-03 620
#> 4: 2024-11-04 638
#> 5: 2024-11-05 581
#> 6: 2024-11-06 617
#> 7: 2024-11-07 600
#> 8: 2024-11-08 603
#> 9: 2024-11-09 591
#> 10: 2024-11-10 527
#> 11: 2024-11-11 576
#> 12: 2024-11-12 595
#> 13: 2024-11-13 577
#> 14: 2024-11-14 520
#> 15: 2024-11-15 566
#> 16: 2024-11-16 577
#> 17: 2024-11-17 608
#> 18: 2024-11-18 595
#> 19: 2024-11-19 606
#> 20: 2024-11-20 574
#> 21: 2024-11-21 607
#> 22: 2024-11-22 592
#> 23: 2024-11-23 572
#> 24: 2024-11-24 567
#> 25: 2024-11-25 542
#> 26: 2024-11-26 596
#> 27: 2024-11-27 576
#> 28: 2024-11-28 522
#> 29: 2024-11-29 597
#> 30: 2024-11-30 539
#> 31: 2024-12-01 604
#> 32: 2024-12-02 586
#> 33: 2024-12-03 573
#> 34: 2024-12-04 557
#> 35: 2024-12-05 590
#> 36: 2024-12-06 582
#> 37: 2024-12-07 592
#> 38: 2024-12-08 650
#> 39: 2024-12-09 642
#> 40: 2024-12-10 679
#> 41: 2024-12-11 652
#> 42: 2024-12-12 678
#> 43: 2024-12-13 680
#> 44: 2024-12-14 708
#> 45: 2024-12-15 739
#> 46: 2024-12-16 716
#> 47: 2024-12-17 723
#> 48: 2024-12-18 694
#> 49: 2024-12-19 748
#> 50: 2024-12-20 682
#> 51: 2024-12-21 717
#> 52: 2024-12-22 943
#> 53: 2024-12-23 893
#> 54: 2024-12-24 913
#> 55: 2024-12-25 885
#> 56: 2024-12-26 916
#> 57: 2024-12-27 913
#> 58: 2024-12-28 908
#> 59: 2024-12-29 899
#> 60: 2024-12-30 890
#> 61: 2024-12-31 880
#> 62: 2025-01-01 740
#> 63: 2025-01-02 669
#> 64: 2025-01-03 722
#> 65: 2025-01-04 719
#> 66: 2025-01-05 736
#> 67: 2025-01-06 682
#> 68: 2025-01-07 669
#> 69: 2025-01-08 695
#> 70: 2025-01-09 638
#> 71: 2025-01-10 674
#> 72: 2025-01-11 679
#> 73: 2025-01-12 722
#> 74: 2025-01-13 666
#> 75: 2025-01-14 682
#> 76: 2025-01-15 727
#> 77: 2025-01-16 771
#> 78: 2025-01-17 746
#> 79: 2025-01-18 772
#> 80: 2025-01-19 781
#> 81: 2025-01-20 783
#> 82: 2025-01-21 931
#> 83: 2025-01-22 870
#> 84: 2025-01-23 891
#> 85: 2025-01-24 904
#> 86: 2025-01-25 937
#> 87: 2025-01-26 899
#> 88: 2025-01-27 1039
#> 89: 2025-01-28 1379
#> 90: 2025-01-29 1400
#> 91: 2025-01-30 1406
#> 92: 2025-01-31 1369
#> 93: 2025-02-01 1345
#> 94: 2025-02-02 1297
#> 95: 2025-02-03 1398
#> 96: 2025-02-04 1411
#> 97: 2025-02-05 1447
#> date date_count
#> <IDat> <int>