I want to sample 1:n rows from a data-frame randomly, 100 times (i.e. to give 2000 random data-frames).
I'm able to do this for say 10 random rows using the sample_n function:
ran_df <- sample_n(df, 10, replace = TRUE)
But how do I do this for all possible number of rows from my data-frame i.e. 1 row, 2 rows, 3 rows ... 20 rows?
My dataframe looks like this:
bird_sp plant_sp value
1 species_a plant_a 1
2 species_a plant_a 1
3 species_a plant_a 1
4 species_a plant_a 1
5 species_a plant_a 1
6 species_a plant_b 1
7 species_a plant_b 1
8 species_a plant_b 1
9 species_a plant_b 1
10 species_a plant_c 1
11 species_a plant_d 1
12 species_a plant_d 1
13 species_b plant_d 1
14 species_b plant_d 1
15 species_b plant_b 1
16 species_b plant_b 1
17 species_b plant_b 1
18 species_b plant_b 1
19 species_b plant_c 1
20 species_b plant_c 1
Aucun commentaire:
Enregistrer un commentaire