You can try using dplyr::group_by
with any(Correct == 1)
library(dplyr)
df %>%
group_by(ID, Stimuli) %>%
mutate(Correct = +any(Correct == 1))
#------
ID Stimuli Score Correct
<int> <chr> <dbl> <dbl>
1 1 A1 0.046 1
2 1 A1 0.037 1
3 1 A2 -0.261 0
4 1 A2 0.213 0
5 1 A3 0.224 1
6 1 A3 0.001 1
7 2 A1 -1.38 0
8 2 A1 -0.81 0
9 2 A2 -0.03 1
10 2 A2 0.88 1
11 2 A3 0 1
12 2 A3 0.49 1
Data
df <- structure(list(ID = c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L), Stimuli = c("A1", "A1", "A2", "A2", "A3", "A3", "A1",
"A1", "A2", "A2", "A3", "A3"), Score = c(0.046, 0.037, -0.261,
0.213, 0.224, 0.001, -1.38, -0.81, -0.03, 0.88, 0, 0.49), Correct = c(1L,
1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L)), class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"))