# \donttest{
data("cdnow")
clv.cdnow <- clvdata(cdnow, time.unit="w",estimation.split=37,
date.format="ymd")
### TRACKING PLOT
# Plot the actual repeat transactions
plot(clv.cdnow)
# same, explicitly
plot(clv.cdnow, which="tracking")
# plot cumulative repeat transactions
plot(clv.cdnow, cumulative=TRUE)
# Dont automatically plot but tweak further
library(ggplot2) # for ggtitle()
gg.cdnow <- plot(clv.cdnow)
# change Title
gg.cdnow + ggtitle("CDnow repeat transactions")
# Dont return a plot but only the data from
# which it would have been created
dt.plot.data <- plot(clv.cdnow, plot=FALSE)
### FREQUENCY PLOT
plot(clv.cdnow, which="frequency")
# Bins from 0 to 15, all remaining in bin labelled "16+"
plot(clv.cdnow, which="frequency", trans.bins=0:15,
label.remaining="16+")
# Count all transactions, not only repeat
# Note that the bins have to be adapted to start from 1
plot(clv.cdnow, which="frequency", count.repeat.trans = FALSE,
trans.bins=1:9)
### SPENDING DENSITY
# plot customer's average transaction value
plot(clv.cdnow, which="spending", mean.spending = TRUE)
# distribution of the values of every transaction
plot(clv.cdnow, which="spending", mean.spending = FALSE)
### INTERPURCHASE TIME DENSITY
# plot as small points, in blue
plot(clv.cdnow, which="interpurchasetime",
geom="point", color="blue", size=0.02)
### TIMING PATTERNS
# selected customers and annotating them
plot(clv.cdnow, which="timings", ids=c("123", "1041"), annotate.ids=TRUE)
# plot 25 random customers
plot(clv.cdnow, which="timings", ids=25)
# plot all customers
plot(clv.cdnow, which="timings", ids=nobs(clv.cdnow))
# }
Run the code above in your browser using DataLab