  The halfspace depth is a well studied tool of nonparametric statistics in
multivariate spaces, naturally inducing a multivariate generalisation of
quantiles. The halfspace depth of a point with respect to a measure is defined
as the infimum mass of closed halfspaces that contain the given point. In
general, a closed halfspace that attains that infimum does not have to exist.
We introduce a flag halfspace - an intermediary between a closed halfspace and
its interior. We demonstrate that the halfspace depth can be equivalently
formulated also in terms of flag halfspaces, and that there always exists a
flag halfspace whose boundary passes through any given point $x$, and has mass
exactly equal to the halfspace depth of $x$. Flag halfspaces allow us to derive
theoretical results regarding the halfspace depth without the need to
differentiate absolutely continuous measures from measures containing atoms, as
was frequently done previously. The notion of flag halfspaces is used to state
results on the dimensionality of the halfspace median set for random samples.
We prove that under mild conditions, the dimension of the sample halfspace
median set of $d$-variate data cannot be $d-1$, and that for $d=2$ the sample
halfspace median set must be either a two-dimensional convex polygon, or a data
point. The latter result guarantees that the computational algorithm for the
sample halfspace median form the R package TukeyRegion is exact also in the
case when the median set is less-than-full-dimensional in dimension $d=2$.
