Re: [R] help matching rows of a data frame

2017-09-18 Thread Bert Gunter
Yes. My understanding is that you want the identifier to have the same number of rows as the data frame. A slight variant of David's solution would then be: do.call(paste0,x) -- Bert On Mon, Sep 18, 2017 at 8:29 AM, David Winsemius wrote: > > > On Sep 18, 2017, at 5:13 AM, Therneau, Terry M

Re: [R] help matching rows of a data frame

2017-09-18 Thread David Winsemius
> On Sep 18, 2017, at 5:13 AM, Therneau, Terry M., Ph.D. > wrote: > > This question likely has a 1 line answer, I'm just not seeing it. (2, 3, or > 10 lines is fine too.) > > For a vector I can do group <- match(x, unqiue(x)) to get a vector that > labels each element of x. > What is an eq

Re: [R] help matching rows of a data frame

2017-09-18 Thread William Dunlap via R-help
You could use merge() with an ID column pasted onto the table of names, as in > tbl <- data.frame(FirstName=c("Abe","Abe","Bob","Chuck","Chuck"), Surname=c("Xavier","Yates","Yates","Yates","Zapf"), Id=paste0("P",101:105)) > tbl FirstName Surname Id 1 Abe Xavier P101 2 Abe Yates

Re: [R] help matching rows of a data frame

2017-09-18 Thread K. Elo
Hi! 2017-09-18 07:13 -0500, Therneau, Terry M., Ph.D. wrote: > This question likely has a 1 line answer, I'm just not seeing > it.  (2, 3, or 10 lines is  > fine too.) > > For a vector I can do group  <- match(x, unqiue(x)) to get a vector > that labels each  > element of x. Actually, you get a v

Re: [R] help matching rows of a data frame

2017-09-18 Thread Jeff Newmiller
"Label" is not a clear term for data frames, but most data frames have rownames. If dta is a data frame, not a tibble, rownames( dta )[ !duplicated( dta ) ] Or could use row indexes directly which( !duplicated( dta ) ) -- Sent from my phone. Please excuse my brevity. On September 18, 2017 6

Re: [R] help matching rows of a data frame

2017-09-18 Thread Eric Berger
Hi Terry, I take your question to mean how to label distinct rows of a data frame. If that is not your question please clarify. I found the row.match() function in the package prodlim that can be used to solve this. However since your request requires no additional dependencies I borrowed the relev

[R] help matching rows of a data frame

2017-09-18 Thread Therneau, Terry M., Ph.D.
This question likely has a 1 line answer, I'm just not seeing it. (2, 3, or 10 lines is fine too.) For a vector I can do group <- match(x, unqiue(x)) to get a vector that labels each element of x. What is an equivalent if x is a data frame? The result does not have to be fast: the data set