Probability to sell a product with limited variables


How can I obtain the probability to sell the products? and order by the major probability by client?

  here <- data.frame(id = c("1-1","1-1","1-1","1-1","1-1","1-1","1-1","1-1",
                            "1-1","1-1", "1-1","1-1","1-1","1-1","1-1",
                     group = c(1,1,1,2,2,3,3,3,4,4,5,
                     client = c("90-1", "90-1","92-1","92-1","94-1","95-1","96-1",
                     product = c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,
                                 15,16,17, 18, 19, 20))

I don´t know how to mutate the appropiate form with the id, group, client, product... perhaps group_by() client.... or count() the products...

  here %>% mutate(PROBABILITY_OF_BUY = ...)   

I´m trying something like:

  here %>%
  group_by(client, product, sort = T) %>%
  mutate(PROBABILITY_OF_BUY = 1/.............

In my real data, I try this:

    count(client, product, sort = T) %>% 
    mutate(product_total = sum(n),
           product_relative = percent(n/product_total))

But it is not the correct form, because it must be descending by client.
and with that chunk I calculate the percent of everything...

And I need the probability of a client buy product in descending way

Note: I used percent() function with library(scales)
Thank you very much

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.