easyRFM: An easy way to RFM analysis by R
- CRAN: http://cran.r-project.org/web/packages/easyRFM/index.html
- GitHub: https://github.com/hoxo-m/easyRFM
> library(easyRFM)
バージョン: 0.0.1
関数名 | 概略 |
---|---|
easyRFM |
easyR |
rfm_auto |
Automatic RFM amalysis |
rfm_compute_breaks |
Compute breaks |
rfm_generate_data |
Generate sample data for RFM analysis |
rfm_pretty_breaks |
Pretty breaks |
rfm_rdate |
Generate random Date sequence |
rfm_rdatetime |
Generate random dateteime sequence |
rfm_auto
> res <- rfm_generate_data(date_type = "POSIXct") %>% rfm_auto()
> res %>% attributes()
$names
[1] "rfm" "breaks" "classes" "get_table"
[5] "get_sliced_rfm"
rfm_generate_data
模擬データの生成
Arguments
- id_num
- date_type...
char
,Date
,POSIXct
- seed... 乱数
> rfm_generate_data(id_num = 4, date_type = "Date", seed = 179) %>% head(5)
id payment date
1 1 1260 2014-12-11
2 1 5890 2014-12-11
3 2 7060 2014-12-22
4 2 3770 2014-12-10
5 2 7280 2014-12-31
rfm_rdate
Dateクラスオブジェクトをランダムに生成する
Arguments
- n
- begin, end
- by
- tz
> rfm_rdate(n = 10,
+ begin = as.Date("2015-12-25"),
+ end = as.Date("2017-01-01"),
+ by = "days",
+ tz = Sys.timezone()) %>% {
+ print(.)
+ class(.)
+ }
[1] "2016-11-06" "2016-03-10" "2016-08-04" "2016-01-21" "2016-11-17"
[6] "2016-03-11" "2016-04-08" "2016-08-20" "2016-09-21" "2016-05-17"
[1] "Date"
rfm_rdatetime
ランダムなPOSIXctクラスオブジェクトを生成する
> rfm_rdatetime(n = 10,
+ begin = as.POSIXct("2014-12-01", tz = Sys.timezone()),
+ end = as.POSIXct("2015-01-01", tz = Sys.timezone())) %>% {
+ print(.)
+ class(.)
+ }
[1] "2014-12-19 15:31:11 JST" "2014-12-20 01:31:40 JST"
[3] "2014-12-28 18:12:54 JST" "2014-12-22 05:22:42 JST"
[5] "2014-12-05 18:40:19 JST" "2014-12-03 09:09:05 JST"
[7] "2014-12-11 20:59:48 JST" "2014-12-15 09:43:33 JST"
[9] "2014-12-31 23:46:31 JST" "2014-12-20 08:43:18 JST"
[1] "POSIXct" "POSIXt"