[R] combining columns into a "combination index" of the same length

Emmanuel Levy emmanuel.levy at gmail.com
Tue Jul 21 15:21:42 CEST 2015


Hi,

The answer to this is probably straightforward, I have a dataframe and I'd
like to build an index of column combinations, e.g.

col1 col2  --> col3 (the index I need)
A     1           1
A     1           1
A     2           2
B     1           3
B     2           4
B     2           4


At the moment I use:
col3 <- apply(mat[,sel.col], 1, paste0)

But I wonder if another approach could be faster?

Thanks,

Emmanuel

	[[alternative HTML version deleted]]



More information about the R-help mailing list