dimanche 10 avril 2022

Randomly select strings based on multiple criteria in R

I'm trying to select strings based on multiple criteria but so far no success. My vector contains the following strings (a total of 48 strings): (1_A, 1_B, 1_C, 1_D, 2_A, 2_B, 2_C, 2_D... 12_A, 12_B, 12_C, 12_D)

I need to randomly select 12 strings. The criteria are:

  • I need one string containing each number
  • I need exactly three strings that contains each letter.

I need the final output to be something like: 1_A, 2_A, 3_A, 4_B, 5_B, 6_B, 7_C, 8_C, 9_C, 10_D, 11_D, 12_D.

Any help will appreciated.

All the best, Angelica




Aucun commentaire:

Enregistrer un commentaire