I am trying to find a way to determine when a set of columns changes value in a data.frame. Let me get straight to the point, please consider the following example:
x<-data.frame(cnt=1:10, code=rep('ELEMENT 1',10), val0=rep(5,10), val1=rep(6,10),val2=rep(3,10))
data.table version 1.8.10 (stable version in CRAN), there's a(n) (unexported) function called
duplist that does exactly this. And it's also written in C and is therefore terribly fast.
require(data.table) # 1.8.10 data.table:::duplist(x[, 3:5]) #  1 4 5
If you're using the development version of
data.table (1.8.11), then there's a more efficient version (in terms of memory) renamed as
uniqlist, that does exactly the same job. Probably this should be exported for next release. Seems to have come up on SO more than once. Let's see.
require(data.table) # 1.8.11 data.table:::uniqlist(x[, 3:5]) #  1 4 5