title: dplyr sample_n by one variable through another one
body: <p>I have a data frame with a "grouping" variable <code>season</code> and another variable <code>year</code> which is repeated for each month.</p>
  
  <pre><code>df &lt;- data.frame(month = as.character(sapply(month.name,function(x)rep(x,4))),
                    season = c(rep("winter",8),rep("spring",12),rep("summer",12),rep("autumn",12),rep("winter",4)), 
                    year = rep(2021:2024,12))
  </code></pre>
  
  <p>I would like to use <code>dplyr::sample_n</code> or something similar to choose 2 months in the data frame for each season and keep the same months for all the years, for example:</p>
  
  <pre><code>     month        season     year
  1     January     winter     2021
  2     January     winter     2022
  3     January     winter     2023
  4     January     winter     2024
  5     February    winter     2021
  6     February    winter     2022
  7     February    winter     2023
  8     February    winter     2024
  9     March       spring     2021
  10    March       spring     2022
  11    March       spring     2023
  12    March       spring     2024
  13    May         spring     2021
  14    May         spring     2022
  15    May         spring     2023
  16    May         spring     2024
  17    June        summer     2021
  18    June        summer     2022
  19    June        summer     2023
  20    June        summer     2024
  21    July        summer     2021
  22    July        summer     2022
  23    July        summer     2023
  24    July        summer     2024
  25    October     autumn     2021
  26    October     autumn     2022
  27    October     autumn     2023
  28    October     autumn     2024
  29    November    autumn     2021
  30    November    autumn     2022
  31    November    autumn     2023
  32    November    autumn     2024
  
  </code></pre>
  
  <p>I cannot make <code>df %&gt;% group_by(season,year) %&gt;% sample_n(2)</code> since it chooses different months for each year.</p>
  
  <p>Thanks!</p>