Description Usage Arguments Value Note Author(s) References Examples
Takes a sample from a given range (for example, 1 to 100), and a specified resulting vector length (for example, 10), which add up to a specified value.
1 2 3 4 5 6 7 | SampleToSum(
Target = 100,
VecLen = 10,
InRange = 1:100,
Tolerance = 2,
showSum = TRUE
)
|
Target |
The value that the vector should |
VecLen |
The required vector length |
InRange |
The input range that values can be sampled from |
Tolerance |
A "buffer" for the |
showSum |
Logical. Should the resulting total be shown? |
A vector
There is a good chance that with certain settings, this will be VERY SLOW!
Ananda Mahto
http://stackoverflow.com/a/14687223/1270695
1 2 3 4 5 6 7 8 9 10 11 12 | set.seed(1)
SampleToSum()
SampleToSum()
SampleToSum(Tolerance = 0)
SampleToSum(Tolerance = 0)
set.seed(123)
## You'll have to wait a few seconds here
SampleToSum(Target = 1163, VecLen = 15, InRange = 50:150)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.