我在 O'Reilly 的演示文稿中找到了下图(http://cdn.oreillystatic.com/en/assets/1/event/85/Case%20Study_%20What_s%20a%20Customer%20Worth_%20Presentation.pdf)
是否可以在 R 中使用基本图形、格子或 ggplot2 重新创建此图?
这是一些玩具数据:
set.seed(123)
number_of_observations <- 20
number_of_customers <- 5
day_start <- "2013/01/01"
day_end <- "2013/12/31"
d <- data.frame(id=letters[sample(number_of_customers, size=number_of_observations, replace=TRUE)],
date=sample(seq.Date(as.Date(day_start),as.Date(day_end),by="day"), size=number_of_observations, replace=TRUE),
amount=sample(1000, size=number_of_observations, replace=TRUE))
d_sorted <- d[order(d$id, d$date),]
d_sorted
# id date amount
# a 2013-01-09 561
# a 2013-03-20 754
# a 2013-09-16 139
# b 2013-04-27 896
# b 2013-10-04 128
# b 2013-11-21 143
# c 2013-02-23 858
# c 2013-04-16 266
# c 2013-07-18 234
# c 2013-08-22 414
# c 2013-10-18 122
# c 2013-11-26 443
# d 2013-09-10 415
# d 2013-09-10 799
# e 2013-03-26 375
# e 2013-06-24 207
# e 2013-08-05 466
# e 2013-08-28 153
# e 2013-12-18 46
# e 2013-12-29 369
谢谢你的帮助。