Random row, keeping columns together

Standalone 2021.1.2

What I want: draw text in one of two locations, never both locations in the same trial. Random without replacement.

What I’ve done initially: 2 columns in an Excel file, with each row having EITHER: the text (‘X’) or a blank cell. Then in builder, I have two text objects that get the text from each column

Problem: it seems to get a different random for each, so on some trials an X appears in either text location as expected, but on some trials it puts both.

Another alternative: I solved it with a X and Y columns in Excel, where all values in Y are the same, and then specified a constant text X at position $(x,y). Now how would I do that where x and y can be different locations (like in a grid), but preserve equal chance and # of iterations? I’m not sure which direction is best to go.

You’re most of the way there. What you want is just a single text component, with its location controlled by a column or columns in the conditions file. You would then only have a single column for the text content. But if it is always the same value (“X”), then you don’t even need that column. Just put a constant value of X in the text field. Then all that alters on each trial is the position of that text.

The randomness without replacement is handled by the random or full random setting of the loop dialog.

Thanks, it was easier once I figured out the syntax: $(x,y) not ($x, $y)

I still couldn’t get the randomness working, with regular random, not full replacement. It picks all the rows a single time each, but not always the same row, different column in two components. I see how the coded location works better anyway.

I’m not quite sure what you mean here. Can you give some more detail of what you need, and what the current problem is?

It’s not really a problem, as I solved it the other way. But to be explicit:

  1. I solved it by using one Text component, and picking the x,y position from a single column in an Excel document.

  2. The other way I thought of is to use two Text components at fixed locations, and then draw from two columns, one of which has the character I want (X) and the other blank (i.e. draw nothing). Each row has in X in one of the two columns, never both. Then using either random or fullRandom, I’d want it so it grabs a random number at the start of the loop, and uses the same number to pick the same row from both columns, so every trial is either (“X”, “”) or ("", “X”). Instead, it seems to get a different random each time it pulls up a Text component, so it can be (“X”, “”) or ("", “X”) or (“X”, “X”).

Hope that second one made sense. I assume I can do it with code, I just thought the random would have the same value in the entire component.

Th random selection is indeed of an entire row of values per iteration of loop. If you are seeing different behaviour, you must be doing something a little bit special…

Just locations at e.g. (-0.5, 0) and (0.5, 0) for two objects, the text is $col1 and $col2, Excel columns named the same. Both texts are set to change on repeat.