According to the help file, the dplyrfunction sample_ndisplays a fixed number for each group.
When I run the following code, I expect two samples to combine tobgp and alcgp, thus 32 (4 * 4 * 2) lines. However, only two rows are returned.
by_tobgp_alcgp <- esoph %>% group_by(tobgp,alcgp)
sample_n(by_tobgp_alcgp , 2)
It is right? Is there an alternative way to achieve this using dplyr?
source
share