i would like to get a new variable lastocc
with the values 1 and 2. the variable lastocc
should show for each word if its last occurrence was shown also in the same color or not.
So, in case when the particular word was shown now and previous time in the same color, it should be coded as 1. if in its last occurrence it was shown in difference color , it should be coded 2.
for example:
trial word color lastocc
1 warm red
2 klein blue
3 ganz yellow
4 warm red 1
5 klein red 2
6 ganz yellow 1
7 klein red 1
i tried this code and its not working:
data_expblocks$lastocc <- if (data_expblocks$word == TRUE & data_expblocks$color == TRUE) {lastocc = 1}
else { lastocc =2 }
hier is dput() =
structure(list(Subject = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), Word = c("XXXX", "XXXX", "warm", "klein", "klein", "warm",
"ganz", "warm", "leicht", "ganz"), Colour = c("YELLOW", "RED",
"RED", "RED", "RED", "RED", "RED", "YELLOW", "RED", "YELLOW")), row.names = 53:62, class = "data.frame")
would be nice if you can advise me something. thank you!