Skip to content

Cost-benefit/value for money analysis

2 messages · Graham Smith, Joshua Ulrich

#
This really doesn't have anything to do with finance, but I was bored
waiting for something to run.  Please direct any questions to me
off-list or to R-help, since this is not on-topic for this list.
On Tue, Jan 4, 2011 at 12:54 PM, Graham Smith <myotistwo at gmail.com> wrote:
set.seed(21)
p <- trunc(runif(10)*100) # prices
v <- trunc(runif(10)*10)  # values
bk <- letters[1:10]    # books
nb <- 3                # number of books to choose
pc <- combn(p,nb,sum)  # price combinations of 3 books
vc <- combn(v,nb,sum)  # value combinations of 3 books
bc <- combn(bk,nb)     # books in each combination

plot(vc/pc)            # value for money
bc[,which.max(vc/pc)]  # best combination of value for money
Everything above was done with the base R packages.

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com