I want to remove duplicate combinations of sessionid, qf and qn from the following data
sessionid qf qn city 1 9
duplicated() has a method for data.frames, which is designed for just this sort of task:
duplicated()
data.frame
df <- data.frame(a = c(1:4, 1:4), b = c(4:1, 4:1), d = LETTERS[1:8]) df[!duplicated(df[c("a", "b")]),] # a b d # 1 1 4 A # 2 2 3 B # 3 3 2 C # 4 4 1 D