Description Usage Arguments Details Value Examples
Fitting a cumulative booking matrix for hotel booking data
1 | fitCumuBookMat(hotelData, ...)
|
hotelData |
a data.frame with the variables of the booking origin, the target date and the horizon of departure. |
... |
arguments to be used to form the default |
fitCumuBookMat
fits a cumulative booking matrix of the provided data.frame.
An object of class "data.frame"
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## create sample
date_from <- sort(as.Date(runif(20000, min=1, max=700),origin = "2015-01-01"))
date_creation <- round(runif(20000, min = 1, max = 365), digits = 0)
date_to <- round(rnorm(20000, mean = 2, sd = 1), digits = 0)
hotelData2 <- data.frame(date_creation, date_from, date_to)
hotelData2$date_to <- as.Date(hotelData2$date_from + hotelData2$date_to)
hotelData2$date_creation <- as.Date(hotelData2$date_from - hotelData2$date_creation)
hotelData2 <- data.frame(subset(hotelData2, hotelData2$date_to >= hotelData2$date_from & hotelData2$date_from >= hotelData2$date_creation))
rownames(hotelData2) <- seq(length(hotelData2$date_creation),from = 1)
rm(date_creation, date_from, date_to)
hotelDataApply <- lapply(1:nrow(hotelData2), function(i) seq(hotelData2$date_from[i], hotelData2$date_to[i], by = "day"))
hotelData2 <- data.frame(origin = rep(hotelData2$date_creation, sapply(hotelDataApply, length)), target = do.call("c", hotelDataApply))
hotelData2 <- hotelData2[hotelData2$target <= max(hotelData2$origin), , drop = FALSE]
hotelData2$horizon <- as.numeric(hotelData2$target - hotelData2$origin)
## use function with sample hotelData2
bookMat <- fitCumuBookMat(hotelData = hotelData2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.