Good morning,

 

I am facing a problem very easy to solve with a program, but not too
easy (at least IMHO) with a "declarative" approach.

I have a dataframe df with some information about bank branches with a
validity time associated (start date/end date, format YYYY-MM-DD) to
some attributes (for example number of employees assigned).

 

The following example will clarify this description:

 

BANK_ID     BRANCH_ID   EMPLOYEE #  STARTDATE   ENDDATE     

B1          A15         30          2001-01-01  2001-10-15

B1          A15         28          2001-10-16  2001-12-31

B1          A15         32          2002-01-01  2003-04-18

B1          A15         33          2003-04-19  2004-12-31

B1          A15         29          2005-03-01  2010-12-31

B1          A15         30          2011-02-12  9999-12-31

........................................................................
........................................................................
.....................

 

I would like to find the "missing time intervals" ("holes" - in the
example 2005-01-01 to 2005-02-28 and from 2011-01-01 to 2011-02-11).

The "programmer's way" would be:

 

*         Sort the data by "key" + start date

*         For each occurrence add 1 day to end date and compare the
result with the start date of the following occurrence

 

Can someone help me in finding a "declarative" way to do it ?

 

Thank you in advance

 

Angelo Linardi

 

 

 

 


** Le e-mail provenienti dalla Banca d'Italia sono trasmesse in buona fede e 
non 
comportano alcun vincolo ne' creano obblighi per la Banca stessa, salvo che 
cio' non 
sia espressamente previsto da un accordo scritto.
Questa e-mail e' confidenziale. Qualora l'avesse ricevuta per errore, La 
preghiamo di 
comunicarne via e-mail la ricezione al mittente e di distruggerne il contenuto. 
La 
informiamo inoltre che l'utilizzo non autorizzato del messaggio o dei suoi 
allegati 
potrebbe costituire reato. Grazie per la collaborazione.
-- E-mails from the Bank of Italy are sent in good faith but they are neither 
binding on 
the Bank nor to be understood as creating any obligation on its part except 
where 
provided for in a written agreement. This e-mail is confidential. If you have 
received it 
by mistake, please inform the sender by reply e-mail and delete it from your 
system. 
Please also note that the unauthorized disclosure or use of the message or any 
attachments could be an offence. Thank you for your cooperation. **
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to