Description Usage Arguments Value Author(s) Examples
Sample blockwise from clustered data
1 | blocksample(data, size, idvar = "id", replace = TRUE, ...)
|
data |
Data frame |
idvar |
Column defining the clusters |
size |
Size of samples |
replace |
Logical indicating wether to sample with replacement |
... |
additional arguments to lower level functions |
data.frame
Klaus K. Holst
1 2 3 4 5 6 7 8 | d <- data.frame(x=rnorm(5), z=rnorm(5), id=c(4,10,10,5,5), v=rnorm(5))
(dd <- blocksample(d,size=20))
attributes(dd)$id
## Not run:
blocksample(data.table::data.table(d),1e6)
## End(Not run)
|
Loading required package: timereg
Loading required package: survival
Loading required package: lava
lava version 1.5
mets version 1.2.2
x z id v
5 -1.2431171 -0.5691450 5 -1.08443759
3 -0.3433448 0.1222036 10 -1.28982707
3.1 -0.3433448 0.1222036 10 -1.28982707
2 -3.0635359 0.7011888 10 -1.39236049
1 -0.6195613 0.6724893 4 0.74298009
1.1 -0.6195613 0.6724893 4 0.74298009
5.1 -1.2431171 -0.5691450 5 -1.08443759
2.1 -3.0635359 0.7011888 10 -1.39236049
4 0.5767734 -1.9210679 5 0.03634879
5.2 -1.2431171 -0.5691450 5 -1.08443759
1.2 -0.6195613 0.6724893 4 0.74298009
2.2 -3.0635359 0.7011888 10 -1.39236049
4.1 0.5767734 -1.9210679 5 0.03634879
4.2 0.5767734 -1.9210679 5 0.03634879
2.3 -3.0635359 0.7011888 10 -1.39236049
3.2 -0.3433448 0.1222036 10 -1.28982707
3.3 -0.3433448 0.1222036 10 -1.28982707
5.3 -1.2431171 -0.5691450 5 -1.08443759
3.4 -0.3433448 0.1222036 10 -1.28982707
2.4 -3.0635359 0.7011888 10 -1.39236049
NULL
x z id v
1: -0.3433448 0.1222036 10 -1.28982707
2: -0.6195613 0.6724893 4 0.74298009
3: -0.6195613 0.6724893 4 0.74298009
4: -0.6195613 0.6724893 4 0.74298009
5: -0.6195613 0.6724893 4 0.74298009
---
999996: -3.0635359 0.7011888 10 -1.39236049
999997: -0.6195613 0.6724893 4 0.74298009
999998: 0.5767734 -1.9210679 5 0.03634879
999999: -3.0635359 0.7011888 10 -1.39236049
1000000: -0.3433448 0.1222036 10 -1.28982707
Warning message:
system call failed: Cannot allocate memory
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.