Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pf <- data.frame(promodata)
- nopromo <- pf[pf$PromoOrNot=="NoPromo",]
- promo <- pf[pf$PromoOrNot!="NoPromo",]
- npremained <- length(nopromo[nopromo[nopromo$AmountSpentThisMonth>100,]$SpentOver100DollarsLastMonth=="Yes",]$CustomerID)
- premained <- length(promo[promo[promo$AmountSpentThisMonth>100,]$SpentOver100DollarsLastMonth=="Yes",]$CustomerID)
- npremained <- npremained + length(nopromo[nopromo[nopromo$AmountSpentThisMonth<100,]$SpentOver100DollarsLastMonth=="No",]$CustomerID)
- premained <- premained + length(promo[promo[promo$AmountSpentThisMonth<100,]$SpentOver100DollarsLastMonth=="No",]$CustomerID)
- npbecame <- length(nopromo[nopromo[nopromo$AmountSpentThisMonth>100,]$SpentOver100DollarsLastMonth=="No",]$CustomerID)
- pbecame <- length(promo[promo[promo$AmountSpentThisMonth>100,]$SpentOver100DollarsLastMonth=="No",]$CustomerID)
- npleft <- length(nopromo[nopromo[nopromo$AmountSpentThisMonth<100,]$SpentOver100DollarsLastMonth=="Yes",]$CustomerID)
- pleft <- length(promo[promo[promo$AmountSpentThisMonth<100,]$SpentOver100DollarsLastMonth=="Yes",]$CustomerID)
- became <- c(pbecame,npbecame)
- left <- c(pleft,npleft)
- remained <- c(premained,npremained)
- print("Proportion of people who spent more who received the promotion:")
- print((pbecame)/(pbecame+npbecame))
- print("Proportion of people who remained who received the promotion:")
- print((premained)/(premained+npremained))
- print("Proportion of people who spent less who received the promotion:")
- print((pleft)/(pleft+npleft))
- print("Proportion of people who spent more who received the promotion:")
- print(pbecame/(pbecame+pleft+premained))
- print("Proportion of people who spent more who did not receive the promotion:")
- print(npbecame/(npbecame+npleft+npremained))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement