This is similar to what I am trying to do as well, and the script you posted for choosing a subset of items has really helped me a lot! I have a few issues though:
1. With your script I have managed to choose a subset of items from my target and filler stimuli, but I have the same issue as Maddie that when I choose 29 out of 44 items, I’m only getting the 29 first items in my table. I tried to implement your comment with the >= comparison, but I am still only getting the first 29 items. Is there any way to solve this?
2. I have three categories of stimuli: alternating targets, non-alternating targets, and fillers. In the training part of my experiment, participants will be shown 29 out of 44 alternating targets, 17 out of 22 non-alternating targets, and all 18 fillers. Except for the issue in 1, I have this part solved.
In the testing part of the experiment, I want to choose 30 alternating targets, 10 non-alternating targets and 10 fillers. Crucially, for both the alternating and the non-alternating targets, I want half of the items in the testing phase to be items that were already shown in training and the other half to be the remaining 15 (for alternating targets) and 5 (for non-alternating targets) items in the table. Do you know if there is any way to implement this?