% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/filter-index.R
\name{filter_index}
\alias{filter_index}
\title{A shorthand for filtering time index for a tsibble}
\usage{
filter_index(.data, ..., .preserve = FALSE)
}
\arguments{
\item{.data}{A tsibble.}

\item{...}{Formulas that specify start and end periods (inclusive), or strings.
\itemize{
\item \code{~ end} or \code{. ~ end}: from the very beginning to a specified ending period.
\item \code{start ~ end}: from specified beginning to ending periods.
\item \code{start ~ .}: from a specified beginning to the very end of the data.
Supported index type: \code{POSIXct} (to seconds), \code{Date}, \code{yearweek}, \code{yearmonth}/\code{yearmon},
\code{yearquarter}/\code{yearqtr}, \code{hms}/\code{difftime} & \code{numeric}.
}}

\item{.preserve}{Relevant when the \code{.data} input is grouped.
If \code{.preserve = FALSE} (the default), the grouping structure
is recalculated based on the resulting data, otherwise the grouping is kept as is.}
}
\description{
This shorthand respects time zones and encourages compact expressions.
}
\section{System Time Zone ("Europe/London")}{

There is a known issue of an extra hour gained for a machine setting time
zone to "Europe/London", regardless of the time zone associated with
the POSIXct inputs. It relates to \emph{anytime} and \emph{Boost}. Use \code{Sys.timezone()}
to check if the system time zone is "Europe/London". It would be recommended to
change the global environment "TZ" to other equivalent names: GB, GB-Eire,
Europe/Belfast, Europe/Guernsey, Europe/Isle_of_Man and Europe/Jersey as
documented in \code{?Sys.timezone()}, using \code{Sys.setenv(TZ = "GB")} for example.
}

\examples{
# from the starting time to the end of Feb, 2015
pedestrian \%>\%
  filter_index(~ "2015-02")

# entire Feb 2015, & from the beginning of Aug 2016 to the end
pedestrian \%>\%
  filter_index("2015-02", "2016-08" ~ .)

# multiple time windows
pedestrian \%>\%
  filter_index(~"2015-02", "2015-08" ~ "2015-09", "2015-12" ~ "2016-02")

# entire 2015
pedestrian \%>\%
  filter_index("2015")

# specific
pedestrian \%>\%
  filter_index("2015-03-23" ~ "2015-10")
pedestrian \%>\%
  filter_index("2015-03-23" ~ "2015-10-31")
pedestrian \%>\%
  filter_index("2015-03-23 10" ~ "2015-10-31 12")
}
\seealso{
\link{time_in} for a vector of time index
}
