William Dunlap wdunlap at tibco.com
Fri Aug 26 01:17:09 CEST 2016

```If you label opening times with +1 and closing times with -1 then
cumsum(thoseLabels) will tell you how many shops are open immediately after
each of those times.  You can use findInterval() on the times to map an
arbitrary time to the number of shops open at that time.  You do need to
deal with starting values so that the first label for each shop is +1.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Thu, Aug 25, 2016 at 3:14 PM, Jim Lemon <drjimlemon at gmail.com> wrote:

> Hi Alexander,
> A time series comes to mind, but perhaps all you need is a matrix with
> 0s for closed and 1s for open. Each row is a shop. Column names as the
> times and the resolution is up to you. I think colSums will produce
> what you want.
>
> Jim
>
> On Fri, Aug 26, 2016 at 1:10 AM, alexander.sommer at tu-dortmund.de
> <alexander.sommer at tu-dortmund.de> wrote:
> > Hi fellow R-users,
> >
> > I am wondering about the best way to store business hours and the like
> in R. (Best in the sense of best for analyzing them.)
> >
> > Say, I got a number of “shops”:
> > Shop A opens at 8am and closes at 8pm;
> > shop B opens at 9am, closes at 11.45am for a siesta, reopens at 1.30pm
> and closes at 5pm;
> > and so forth.
> >
> > To simplify things, I would assume that closing a shop for more than two
> times and reopening it for more than one time is not possible. (Hoping to
> avoid problems with shops having multiple siestas and business hours beyond
> midnight this way.)
> >
> > My first idea would be to plot something like an empirical distribution
> function for this data. (Having only shops A and B, this would be zero
> until 8am, 50 % from 8am to 9am, 100 % from 9am to 11.45am, 50 % again from
> 11.45am to 1.30pm, 100 % again from 1.30pm to 5pm, yet again 50 % from 5pm
> to 8pm and falling back to zero from 8pm on.) But general arithmetic should
> be possible, especially for building a mean over some days.
> >
> > Any ideas?
> >
> > Cheers,
> >
> > Alex
> >
> >
> > --
> > Alexander Sommer
> > wissenschaftlicher Mitarbeiter
> >
> > Technische Universität Dortmund
> > Fakultät Erziehungswissenschaft, Psychologie und Soziologie
> > Forschungsverbund Deutsches Jugendinstitut/Technische Universität
> Dortmund
> > Vogelpothsweg 78
> > 44227 Dortmund
> >
> > Telefon: +49 231 755-8189
> > Telefax: +49 231 755-6553
> > E-Mail:  alexander.sommer at tu-dortmund.de
> > WWW:     http://www.forschungsverbund.tu-dortmund.de/
> >
> >
> > Wichtiger Hinweis: Die Information in dieser E-Mail ist vertraulich. Sie
> ist ausschließlich für den Adressaten bestimmt. Sollten Sie nicht der für
> diese E-Mail bestimmte Adressat sein, unterrichten Sie bitte den Absender
> und vernichten Sie diese Mail. Vielen Dank.
> > Unbeschadet der Korrespondenz per E-Mail, sind unsere Erklärungen
> ausschließlich final rechtsverbindlich, wenn sie in herkömmlicher
> Schriftform (mit eigenhändiger Unterschrift) oder durch Übermittlung eines
> solchen Schriftstücks per Telefax erfolgen.
> >
> > Important note: The information included in this e-mail is confidential.
> It is solely intended for the recipient. If you are not the intended
> Thank you. Without prejudice of e-mail correspondence, our statements are
> only legally binding when they are made in the conventional written form
> (with personal signature) or when such documents are sent by fax.
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help