first of all, thank you for everything you are doing. I am currently trying to wrap my head around a problem (new to r). I have a small n dataframe (e.g., n=10
) but I want to have a new dataframe that consists of more of those observations (e.g., n=15
).
The one condition is that I have to make sure that every value (i.e., row) of the old dataset appears at least once in the new dataset.
Using sample, I could not achieve this - some rows were missing some of the times.
EDIT Simple Example:
df = data.frame(matrix(rnorm(20), nrow = 10))
df[sample(nrow(df), 14, replace = TRUE), ]
X1 X2
9 0.5881409 0.1967030
2 1.1227569 1.9827646
1 1.2225747 0.3428867
10 -0.2780021 -2.3581644
4 0.4687276 -2.2431019
5 1.4592202 -0.6397336
7 -0.8779913 0.4293624
3 -0.1663962 -0.2435444
3.1 -0.1663962 -0.2435444
3.2 -0.1663962 -0.2435444
1.1 1.2225747 0.3428867
1.2 1.2225747 0.3428867
6 -1.0797652 -1.1893041
7.1 -0.8779913 0.4293624
However, we see that for example row 8 is missing.