View source: R/methods-epi_archive.R
filter.epi_archive | R Documentation |
dplyr::filter
for epi_archive
sdplyr::filter
for epi_archive
s
## S3 method for class 'epi_archive'
filter(.data, ..., .by = NULL, .format_aware = FALSE)
.data |
an |
... |
as in |
.by |
as in |
.format_aware |
optional, |
By default, using the version
column or measurement columns is disabled as
it's easy to get unexpected results. See if either epix_as_of
or
epix_slide
works for any version selection you have in mind: for version
selection, see the version
or .versions
args, respectively; for
measurement column-based filtering, try filter
ing after epix_as_of
or
inside the .f
in epix_slide()
. If they don't cover your use case, then
you can set .format_aware = TRUE
to enable usage of these columns, but be
careful to:
Factor in that .data$DT
may have been converted into a compact format
based on diffing consecutive versions, and the last version of each
observation in .data$DT
will always be carried forward to future
version
s; see details of [
as_epi_archive'].
Set clobberable_versions_start
and versions_end
of the result
appropriately after the filter
call. They will be initialized with the
same values as in .data
.
dplyr::filter
also has an optional argument .preserve
, which should not
have an impact on (ungrouped) epi_archive
s, and grouped_epi_archive
s do
not currently support dplyr::filter
.
# Filter to one location and a particular time range:
archive_cases_dv_subset %>%
filter(geo_value == "fl", time_value >= as.Date("2020-10-01"))
# Convert to weekly by taking the Saturday data for each week, so that
# `case_rate_7d_av` represents a Sun--Sat average:
archive_cases_dv_subset %>%
filter(as.POSIXlt(time_value)$wday == 6L)
# Filtering involving the `version` column or measurement columns requires
# extra care. See epix_as_of and epix_slide instead for some common
# operations. One semi-common operation that ends up being fairly simple is
# treating observations as finalized after some amount of time, and ignoring
# any revisions that were made after that point:
archive_cases_dv_subset %>%
filter(
version <= time_value + as.difftime(60, units = "days"),
.format_aware = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.