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

2015-07-21 Thread Emmanuel Levy
Thanks Thierry, you made my day :) On 21 July 2015 at 17:00, Thierry Onkelinx thierry.onkel...@inbo.be wrote: Please always keep the mailing list in cc. If mat is a data.frame, then you can use do.call. Then the number of columns doesn't matter. do.call(paste, mtcars[, c(mpg, cyl)])

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

2015-07-21 Thread Thierry Onkelinx
Please always keep the mailing list in cc. If mat is a data.frame, then you can use do.call. Then the number of columns doesn't matter. do.call(paste, mtcars[, c(mpg, cyl)]) do.call(paste, mtcars[, c(mpg, cyl, disp)]) do.call(paste, mtcars) ir. Thierry Onkelinx Instituut voor natuur- en

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

2015-07-21 Thread Emmanuel Levy
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

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

2015-07-21 Thread Thierry Onkelinx
Yes. paste0() can work on vectors. So paste0(mat[, col1], mat[, col2]) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in