0

A have a problem. I have a data frame byDays, which consists of two columns: day and money. Day looks like sequence from 0 to 100. And Money means amount of money, our customers spent in this day. I plotted distribution, but cant link it, havent got enough reputation.

And i need to find a day(!) left from which will be 80% of area of my distibution.

Slavka
  • 1,070
  • 4
  • 13
  • 28
  • 2
    It's hard to offer much help if without some data. Could you provide some sample data? http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – r.bot May 06 '15 at 19:27
  • Do you mean the cumulative money? – DatamineR May 06 '15 at 19:30

1 Answers1

2

If you want the point at which 80% of the total is reached this will give you the answer:

set.seed(1)
day <- 1:100
profit <- runif(100, 0, 15)

##  Point at which 80% of the total is reached:
pct <- max(x[ cumsum(profit)/sum(profit) <= 0.8])

plot(day, cumsum(profit)/sum(profit))
abline(v=pct, col="red")

Day at which 80% of total profit is reached

Forrest R. Stevens
  • 3,435
  • 13
  • 21