On Wed, 28 Feb 2018, Stephen HonKit Wong wrote:
Dear All, Suppose I have a dataframe like this with many thousands rows all with different names: data.frame(gene=c("a","b","c","d","c","d","c","f"),value=c(20,300,48,55,9,2,100,200)),I want to set column "gene" as row.names, but there are duplicates (c, d), which I want to transform into this as row names: a, b, c-1, d-1, c-2, d-2, c-3, f
a) My reaction is that this doesn't actually sound like a very useful thing to do, so I caution you to beware of trying to accomplish too much with this capability... if it continues to be difficult to do what you want once you have these row names that appear nowhere else in your data, start looking for other ways to obtain the actual answers you want.
b) If your data frame is stored in `dta`, then you can do rownames( dta ) <- make.names( dta$gene, unique = TRUE, sep="-" ) --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<[email protected]> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k ______________________________________________ [email protected] 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.

