Skip to content
Prev 371414 / 398513 Next

help matching rows of a data frame

Hi!
2017-09-18 07:13 -0500, Therneau, Terry M., Ph.D. wrote:
Actually, you get a vector of indices matching 'unique(x)', not a
labelled vector.
[1] 1 2 3 1 3 4
So you will generate an index where duplicated rows have the row index
of the first occurrence, right? This could work:
? ? ?for (j in (i+1):nrow(x)) {?
? ? ? ? if (sum(as.numeric(x[i,]==x[j,]))==ncol(x)) {?
? ? ? ? ? ?group[j]<-group[i] }
? ? ?}
? ?}
[1] "1" "2" "3" "3" "5" "1"

HTH,
Kimmo