Hello i hope this is not a duplicate question, but probably a very simple one. I couldn´t find the answer and i can´t solve it by my self.
i have a dataframe like below and i need to make a random selection of one row within each "id_lote". "id_pix" are unique but "id_lote" are repeated and the size of the groups (id_lote) are different. My result should be a subset dataframe with many rows as id_lote but randomly selected. I´m using sample command for other random selections but i can´t make it work for this issue. If i use unique command it won´t be a random subset... thanks in advance!
id_pix id_lote clase f1 f2
45 4 Sg 2460 2401
46 4 Sg 2620 2422
47 4 Sg 2904 2627
48 5 M 2134 2044
49 5 M 2180 2104
50 5 M 2127 2069
83 11 S 2124 2062
84 11 S 2189 2336
85 11 S 2235 2162
86 11 S 2162 2153
87 11 S 2108 2124