Dimitri Shvorob
2010-Jan-29 23:06 UTC
[R] How to choose a number subset with sum closest to x?
I am looking for a function that, when supplied a vector of floats x, an integer n, and float s, would find me an n-subset of x with the sum closest to s. Can anyone point me to a package/function that can do the job - better yet, provide a relevant code sample? (There are a few relevant packages on CRAN, but lack of examples in their docs is a real problem). Thank you. -- View this message in context: http://n4.nabble.com/How-to-choose-a-number-subset-with-sum-closest-to-x-tp1439939p1439939.html Sent from the R help mailing list archive at Nabble.com.
Charles C. Berry
2010-Jan-30 06:07 UTC
[R] How to choose a number subset with sum closest to x?
On Fri, 29 Jan 2010, Dimitri Shvorob wrote:> > I am looking for a function that, when supplied a vector of floats x, an > integer n, and float s, would find me an n-subset of x with the sum closest > to s. Can anyone point me to a package/function that can do the job - better > yet, provide a relevant code sample? (There are a few relevant packages on > CRAN, but lack of examples in their docs is a real problem). >See if this helps: http://finzi.psych.upenn.edu/Rhelp08/2009-November/218369.html HTH, Chuck> Thank you. > -- > View this message in context: http://n4.nabble.com/How-to-choose-a-number-subset-with-sum-closest-to-x-tp1439939p1439939.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901