#' Take some pageviews, output Markov model prediction
#'
#' @param pageview_names A character vector of pageview names
#'
#' @return The prediction
#' @import clickstream
#' @export
predictNextPage <- function(pageview_names) {
## model loaded on package load
states <- invisible(clickstream::states(model))
pv_n <- pageview_names[pageview_names %in% states]
startPattern <- new("Pattern", sequence = pv_n)
predict <- predict(model, startPattern)
list(page = predict@sequence,
probability = predict@probability)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.