dc.RemoveTimeBetween {BTYD}R Documentation

Remove Time Between


This function creates a new event log, with time in the middle removed. Used, for example, in sports with off-seasons.


dc.RemoveTimeBetween(elog, day1, day2, day3, day4)



event log, which is a data frame with columns for customer ID ("cust"), date ("date"), and optionally other columns such as "sales". Each row represents an event, such as a transaction. The "date" column must consist of date objects, not character strings.


date of beginning of first period. Must be a date object.


date of end of first period. Must be a date object.


date of beginning of second period. Must be a date object.


date of third period. Must be a date object.


The four date parameters must be in ascending order.


list - elog1 the event log with all elog$date entries between day1 and day2 - elog2 the event with all elog$date entries between day3 and day4 - elog3 elog1 combined with elog2, with all dates from elog2 reduced by the time removed between elog1 and elog2


elog <- dc.ReadLines(system.file("data/cdnowElog.csv", package="BTYD"),2,3,5)
elog[,"date"] <- as.Date(elog[,"date"], "%Y%m%d")

# Use the cdnow data to return a 6 month event log for January, February,
# March, October, November, December.
period.one.start <- as.Date("1997-01-01")
period.one.end <- as.Date("1997-03-31")
period.two.start <- as.Date("1997-10-01")
period.two.end <- as.Date("1997-12-31")
reduced.elog <- dc.RemoveTimeBetween(elog, period.one.start, period.one.end,
                                     period.two.start, period.two.end)

# Note that the new elog will go up to June 30 at a maximum, since we
# are only using 6 months of data starting on January 1
max(reduced.elog$elog3$date)  # "1997-06-30"

[Package BTYD version 2.4.3 Index]