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 <dwinsem...@comcast.net> wrote: > > > On Sep 18, 2017, at 5:13 AM, Therneau, Terry M., Ph.D. < > thern...@mayo.edu> 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 equivalent if x is a data frame? > > > > In the past I've use apply with past to generate "group" identifiers: > > > x<-data.frame("X0"=c("A","B","C","C","D","A"), "X1"=c(1,2,1,1,3,1)) > > apply(x, 1, paste, collapse=".") > [1] "A.1" "B.2" "C.1" "C.1" "D.3" "A.1" > > > > The result does not have to be fast: the data set will have < 100 > elements. Since this is inside the survival package, and that package is > on the 'recommended' list, I can't depend on any package outside the > recommended list. > > David Winsemius > Alameda, CA, USA > > 'Any technology distinguishable from magic is insufficiently advanced.' > -Gehm's Corollary to Clarke's Third Law > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.