#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

# Struggling to create a specific column

Hello everyone,

This is my first post here, so I apologize if I am formatting my question incorrectly.

I am busy preparing to conduct an experiment focused on the pupillary responses to various images (attached is a reference image of my preliminary data). To attain an actual measure of dilation, I need to subtract each subject's control response from their critical response (left and right eye values averaged = LR Average). It is crucial that this subtraction is within-subject, as pupil size varies at the individual level.

I have also attached a screenshot of the incomplete computation to better explain what I am trying to do. In essence, I would like the "mean(LR Average)" that is being subtracted from the initial "LR Average" to exclusively be the average pupil response to "controlimage2.png."

So it would look like: (LR Average - mean(Control LR Average)/SD(LR Average) | ParticipantName

• Hi bertheat,

Unfortunately, I don't think it is possible to do this with the drag and drop interface right now.

A workaround is to use R code, like so:

```dataVar  <- contNormal # change this into LR Average
groupVar <- facFive    # change this into ParticipantName

result <- 0 * dataVar
gg <- unique(groupVar)
for (g in gg) {
idx <- groupVar == g
result[idx] <- scale(dataVar[idx])
}
result
```

you can enter R code by selecting the R symbol when creating a computed column:

After you do that, you can check with Descriptives if it worked out:

The values for the mean are of order 1e-17, which is essentially zero.

Let me know if this works!

Cheers,

Don

• Hey Don,

Thank you so much for replying so thoughtfully! I'll give that a go and let you know how it turns out.

Lambert