Sample rows does not work as expected and raises error that says size must be less or equal

Symptom: sample_n does not work and gives an error

The error would look like Size must be less or equal than xxx (size of data)


How to fix.

If your data frame is Grouped By like below, it suggests one of your group has less rows than the sample size you specified.

So you might want to ungroup your data frame before you run sample_n. If you do want to sample for each group, pass less number of the argument.