0

My apologies for this title, i didn't succeeded to find a good explicit title.

Here is a reproducible code for what my data looks like :

subject = gl(3,4,12)
item = factor(c("A","B","B","A","A","A","B","B","A","B","A","B"))
set.seed(123) 
rt = runif(12, 1000, 2000)
df = data.frame(subject, item, rt)

> df
subject item       rt
1    A 1287.578
1    B 1788.305
1    B 1408.977
1    A 1883.017
2    A 1940.467
2    A 1045.556
2    B 1528.105
2    B 1892.419
3    A 1551.435
3    B 1456.615
3    A 1956.833
3    B 1453.334

I would like to subset my data.frame in order to keep only the first occurence of each item for each subject. For each subject, the item order is random and each item has been seen twice but i would like to keep only the first occurence.

Any idea of a simple way to do this ?

BloodyNoob
  • 103
  • 1
  • 1
  • 6

0 Answers0