Re: [R] split list of characters in groups of 2

2011-11-17 Thread Uwe Ligges
On 17.11.2011 10:31, Dennis Murphy wrote: Hi: Here's one way: apply(matrix(var.names, ncol = 2, byrow = TRUE), 1, function(x) paste(x[1], x[2], sep = ',')) [1] "a,b" "c,d" "e,f" Or for short and slightly faster for huge data use column-wise operations as in: apply(matrix(var.names, nrow=

Re: [R] split list of characters in groups of 2

2011-11-17 Thread Dennis Murphy
Hi: Here's one way: apply(matrix(var.names, ncol = 2, byrow = TRUE), 1, function(x) paste(x[1], x[2], sep = ',')) [1] "a,b" "c,d" "e,f" HTH, Dennis On Wed, Nov 16, 2011 at 9:46 PM, B77S wrote: > hi, > > If i have a list of things, like this > > var.names <- c("a", "b", "c", "d", "e", "f") > >