[英]RFM analysis - using ddply in R. Missing column
I am trying to use the code mentioned for RFM modelling in R from the blog here . 我正在尝试使用此处博客中R中提到的RFM建模代码。 However, grouping the data frame into “Buy” and “No Buy” has not been explained clearly. 但是,没有明确说明将数据框分为“购买”和“不购买”。 As a result, when I try to execute the function getPercentages
, I get error like: 结果,当我尝试执行功能getPercentages
,出现如下错误:
object "Buy" not found. 找不到对象“购买”。
I am trying to add a Buy column as follows: df$Buy <- ifelse(df$Frequency > 1, 1, 0)
before executing the function. 我试图添加如下所示的Buy列: df$Buy <- ifelse(df$Frequency > 1, 1, 0)
在执行该函数之前。 I do not know if this is right way to get the values. 我不知道这是否是获取值的正确方法。 My head for df
after getDataframe
is getDataframe
之后我对df
getDataframe
是
ID Date Amount Recency Frequency Monetary
1207779 2016-06-22 2112.00 8 20 1576.7725
2455590 2016-06-26 1064.00 4 16 1074.8400
2660337 2016-06-21 1870.00 9 20 1616.1700
257997 2016-06-22 616.00 8 22 684.8968
963883 2016-06-27 703.12 3 16 626.1125
1124489 2016-06-21 594.15 9 18 752.2011
Try this : 尝试这个 :
Buy<-rep(0,nrow(dftry))
dftry<-cbind(dftry,Buy)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.