Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. pf <- data.frame(promodata)
  2.  
  3. nopromo <- pf[pf$PromoOrNot=="NoPromo",]
  4. promo <- pf[pf$PromoOrNot!="NoPromo",]
  5.  
  6. npremained <- length(nopromo[nopromo[nopromo$AmountSpentThisMonth>100,]$SpentOver100DollarsLastMonth=="Yes",]$CustomerID)
  7. premained <- length(promo[promo[promo$AmountSpentThisMonth>100,]$SpentOver100DollarsLastMonth=="Yes",]$CustomerID)
  8.  
  9. npremained <- npremained + length(nopromo[nopromo[nopromo$AmountSpentThisMonth<100,]$SpentOver100DollarsLastMonth=="No",]$CustomerID)
  10. premained <- premained + length(promo[promo[promo$AmountSpentThisMonth<100,]$SpentOver100DollarsLastMonth=="No",]$CustomerID)
  11.  
  12. npbecame <- length(nopromo[nopromo[nopromo$AmountSpentThisMonth>100,]$SpentOver100DollarsLastMonth=="No",]$CustomerID)
  13. pbecame <- length(promo[promo[promo$AmountSpentThisMonth>100,]$SpentOver100DollarsLastMonth=="No",]$CustomerID)
  14.  
  15. npleft <- length(nopromo[nopromo[nopromo$AmountSpentThisMonth<100,]$SpentOver100DollarsLastMonth=="Yes",]$CustomerID)
  16. pleft <- length(promo[promo[promo$AmountSpentThisMonth<100,]$SpentOver100DollarsLastMonth=="Yes",]$CustomerID)
  17.  
  18.  
  19. became <- c(pbecame,npbecame)
  20. left <- c(pleft,npleft)
  21. remained <- c(premained,npremained)
  22.  
  23. print("Proportion of people who spent more who received the promotion:")
  24. print((pbecame)/(pbecame+npbecame))
  25. print("Proportion of people who remained who received the promotion:")
  26. print((premained)/(premained+npremained))
  27. print("Proportion of people who spent less who received the promotion:")
  28. print((pleft)/(pleft+npleft))
  29.  
  30. print("Proportion of people who spent more who received the promotion:")
  31. print(pbecame/(pbecame+pleft+premained))
  32. print("Proportion of people who spent more who did not receive the promotion:")
  33. print(npbecame/(npbecame+npleft+npremained))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement