Open aravindhebbali opened 2 months ago
# load library
library(rfm)
# remove recency_days column
data <- rfm_data_customer[, -5]
# analysis date
analysis_date <- as.Date('2007-01-01')
# generate rfm score
score <-
rfm_table_customer(data, customer_id, number_of_orders,
most_recent_visit, revenue, analysis_date)
head(score$rfm)
#> customer_id recency_days transaction_count amount recency_score
#> 1 22086 232 9 777 2
#> 2 2290 115 16 1555 4
#> 3 26377 43 5 336 5
#> 4 24650 64 12 1189 5
#> 5 12883 23 12 1229 5
#> 6 2119 72 11 929 5
#> frequency_score monetary_score rfm_score first_name last_name
#> 1 2 2 222 Maddalena Erie
#> 2 5 5 455 Bradley Sesser
#> 3 1 1 511 Gwenora Asser
#> 4 4 4 544 Hendrick Josh
#> 5 4 5 545 Cathleen Musterd
#> 6 4 3 543 Norrie Brear
#> email
#> 1 merie0@go.com
#> 2 bsesser1@time.com
#> 3 gasser2@issuu.com
#> 4 hjosh3@ed.gov
#> 5 cmusterd4@hc360.com
#> 6 nbrear5@techcrunch.com
Created on 2024-06-14 with reprex v2.0.2
rfm_table_customer()
returns an error in the absence ofrecency_days
column in the customer level data. This happens due to hard coding the column name.Created on 2024-06-14 with reprex v2.0.2