randsplit | R Documentation |
This function draws indices for a random split of a vector into sub-vectors.
randsplit(
n.grid,
n.interval,
method = c("modunif", "random", "weighted"),
weights = numeric(0),
offset = 0,
min.internal = 2
)
n.grid |
number of grid points to divide into intervals |
n.interval |
number of intervals |
method |
method for random splitting: |
weights |
weights for choosing interval boundaries for method |
offset |
offset to shift subset of potential interval boundaries to draw from. To guarantee different intervals on subsequent calls, offset should be increased by one between subsequent calls for the same variable. |
min.internal |
minimum number of internal points between interval boundary points |
the function returns an index vector of length n+1 with the endpoint indices of the random intervals.
randsplit(100,10)
randsplit(100,10)
randsplit(100,10,method="random")
randsplit(100,10,method="weighted",weights=1:100)
for ( i in 1:10 ) print(randsplit(100,10,method="weighted",weights=1:100,offset=i))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.