Hi, I have a data file with all our purchases from last year, it contains the unit price, count, and total dollars spend. Now I'm looking for some way to "classify" all our purchases to find out which purchases are the best ones to find cheaper alternatives. for example: if we only buy 1 item of a product which costs 5 dollar, we maybe can find a cheaper product of 4.5 dollar, but this won't make it on our year budget. On the other hand, there may be some products of 2.5 dollar, but we purchased 1000ths of them, so 2.3 dollar/product can be a significant saving. Instead of searching for each of our products a cheaper alternative (takes a awfull lot of time), I would like to concentrate on a top 20 for example. Maybe calculate the pct contribution to the total budget, and take the top 20? Any other ideas for an approach? Here an example dataframe: dat <- data.frame(item=1:160, unit_price=round(c(runif(80,0,100), runif(80,250,1000)),2), count=round(c(runif(40, 1,10), runif(40,20,1000),runif(40, 1,10), runif(40,20,1000)),0), total=0) dat$total = dat$count*dat$unit_price Bart -- View this message in context: http://r.789695.n4.nabble.com/Year-cost-optimisation-tp3599538p3599538.html Sent from the R help mailing list archive at Nabble.com.