I don't know. Is this what you need?

df <- data.frame(
  a = c(1,2,3,4,5),
  b = c('a','b','c','d','e'),
  c = c(1,'b',3,'d',5),
  d = c('a',2,'c',4,'e'))
df
  a b c d
1 1 a 1 a
2 2 b b 2
3 3 c 3 c
4 4 d d 4
5 5 e 5 e

via apply()

do.call(cbind, apply(df, 2, function(x) data.frame(x,x)))
  a.x a.x.1 b.x b.x.1 c.x c.x.1 d.x d.x.1
1   1     1   a     a   1     1   a     a
2   2     2   b     b   b     b   2     2
3   3     3   c     c   3     3   c     c
4   4     4   d     d   d     d   4     4
5   5     5   e     e   5     5   e     e

via lapply()

do.call(cbind, lapply(df, function(x) data.frame(x,x)))
  a.x a.x.1 b.x b.x.1 c.x c.x.1 d.x d.x.1
1   1     1   a     a   1     1   a     a
2   2     2   b     b   b     b   2     2
3   3     3   c     c   3     3   c     c
4   4     4   d     d   d     d   4     4
5   5     5   e     e   5     5   e     e

Now going out for a jog. Catch you later

Kevin



Source link