csb_date_filter
filters dates to return only the specified date elements.
For example, data can be returned for specific months, years, or portions of months
The month argument can be one of several types. Types cannot be mixed. A numeric argument specifying month is acceptable. Character entry can be one of either 3 letter abbreviations or full month name. Capitalization does not matter.
csb_date_filter(.data, var, day, month, year)
.data | A tibble or data frame |
---|---|
var | A name of column containing date data |
day | A numeric vector of day(s) to include. |
month | A numeric/character vector of month(s) to include. See description for more information on alternate entry formats. |
year | A numeric vector of years(s) to include (2 or 4 digit) |
Returns a filtered version of the input data based on specified date arguments.
csb_date_filter(january_2018, datetimeinit, day = 1)#> # A tibble: 32 x 17 #> requestid datetimeinit probaddress probaddtype callertype neighborhood #> <dbl> <dttm> <chr> <chr> <chr> <dbl> #> 1 1049265 2018-01-01 00:48:30 75 WILLMOR… A WEB 8 #> 2 1049265 2018-01-01 00:48:30 75 WILLMOR… A WEB 8 #> 3 1049266 2018-01-01 05:29:06 6739 VERMO… A WEB 1 #> 4 1049267 2018-01-01 08:53:07 5444 ITASK… A WEB 7 #> 5 1049268 2018-01-01 09:13:22 CASS AVE &… B PHONE 60 #> 6 1049269 2018-01-01 10:12:26 6441 LLOYD… A WEB 42 #> 7 1049270 2018-01-01 10:52:32 3100 WINNE… B PHONE 19 #> 8 1049271 2018-01-01 10:54:43 S GRAND AV… B PHONE 25 #> 9 1049272 2018-01-01 11:07:02 SIDNEY ST … B WEB 25 #> 10 1049273 2018-01-01 12:05:40 5400 N BRO… B PHONE 79 #> # … with 22 more rows, and 11 more variables: ward <dbl>, problemcode <chr>, #> # description <chr>, submitto <chr>, status <chr>, dateinvtdone <dttm>, #> # datetimeclosed <dttm>, prjcompletedate <dttm>, datecancelled <dttm>, #> # srx <dbl>, sry <dbl>csb_date_filter(january_2018, datetimeinit, day = 1:15, month = 1)#> # A tibble: 1,554 x 17 #> requestid datetimeinit probaddress probaddtype callertype neighborhood #> <dbl> <dttm> <chr> <chr> <chr> <dbl> #> 1 1049265 2018-01-01 00:48:30 75 WILLMOR… A WEB 8 #> 2 1049265 2018-01-01 00:48:30 75 WILLMOR… A WEB 8 #> 3 1049266 2018-01-01 05:29:06 6739 VERMO… A WEB 1 #> 4 1049267 2018-01-01 08:53:07 5444 ITASK… A WEB 7 #> 5 1049268 2018-01-01 09:13:22 CASS AVE &… B PHONE 60 #> 6 1049269 2018-01-01 10:12:26 6441 LLOYD… A WEB 42 #> 7 1049270 2018-01-01 10:52:32 3100 WINNE… B PHONE 19 #> 8 1049271 2018-01-01 10:54:43 S GRAND AV… B PHONE 25 #> 9 1049272 2018-01-01 11:07:02 SIDNEY ST … B WEB 25 #> 10 1049273 2018-01-01 12:05:40 5400 N BRO… B PHONE 79 #> # … with 1,544 more rows, and 11 more variables: ward <dbl>, problemcode <chr>, #> # description <chr>, submitto <chr>, status <chr>, dateinvtdone <dttm>, #> # datetimeclosed <dttm>, prjcompletedate <dttm>, datecancelled <dttm>, #> # srx <dbl>, sry <dbl>csb_date_filter(january_2018, datetimeinit, month = "January", year = 09)#> # A tibble: 0 x 17 #> # … with 17 variables: requestid <dbl>, datetimeinit <dttm>, probaddress <chr>, #> # probaddtype <chr>, callertype <chr>, neighborhood <dbl>, ward <dbl>, #> # problemcode <chr>, description <chr>, submitto <chr>, status <chr>, #> # dateinvtdone <dttm>, datetimeclosed <dttm>, prjcompletedate <dttm>, #> # datecancelled <dttm>, srx <dbl>, sry <dbl>#> # A tibble: 0 x 17 #> # … with 17 variables: requestid <dbl>, datetimeinit <dttm>, probaddress <chr>, #> # probaddtype <chr>, callertype <chr>, neighborhood <dbl>, ward <dbl>, #> # problemcode <chr>, description <chr>, submitto <chr>, status <chr>, #> # dateinvtdone <dttm>, datetimeclosed <dttm>, prjcompletedate <dttm>, #> # datecancelled <dttm>, srx <dbl>, sry <dbl>csb_date_filter(january_2018, datetimeinit, day = 1:15, month = 1:6, year = 08:13)#>#> # A tibble: 0 x 17 #> # … with 17 variables: requestid <dbl>, datetimeinit <dttm>, probaddress <chr>, #> # probaddtype <chr>, callertype <chr>, neighborhood <dbl>, ward <dbl>, #> # problemcode <chr>, description <chr>, submitto <chr>, status <chr>, #> # dateinvtdone <dttm>, datetimeclosed <dttm>, prjcompletedate <dttm>, #> # datecancelled <dttm>, srx <dbl>, sry <dbl>