It's a bit tricky to give you exact code without seeing your data or what you'd like to do with it, but I'll take a crack at it.
Assuming your data is currently in a data.frame 'df' and has at least the following three columns:
- Participant ID ('PID' below)
- Score A mean ('A.bar' below)
- Score B mean ('B.bar' below)
I would start by creating a new column defining if the mean for score A is greater than the mean for score B using the following code:
df$A.higher <- df$A.bar > df$B.bar
Now you can use that column (containing logical data, e.g., TRUE/FALSE values) to define your two groups, and you can create new objects using the column.
With the subset function:
Greater_A <- subset(df, select = c('PID', 'A.bar'), subset = A.higher)
Greater_B <- subset(df, select = c('PID', 'B.bar'), subset = !A.higher)
(note that '!' is an inverter, e.g. !TRUE = FALSE)
The subset argument in the subset function (yeah, that can be confusing) will select the rows for which the expression is true.
With the [ ] selector:
Greater_A <- df[df$A.higher,]
Greater_B <- df[!df$A.higher,]
Using the [ ] example will grab all of the columns, and the subset function will only grab the columns named in the select argument.
Hope that helps, let me know if you have any questions.