This question is a little different from previous post. I have several columns of random indicator variables and I want to merge them into a sequence "without space". My data is like the following .
ID COL1 COL2 COL3 COL4 COL5 COL6 COL7
1 1 a b c d e f g
2 2 a b c d e f g
3 3 a b c d e f g
4 4 a b c d e f g
5 5 a b c d e f g
6 6 a b c d e f g
7 7 a b c d e f g
8 8 a b c d e f g
ID<-c(1,2,3,4,5,6,7,8)
COL1<-c('a','a','a','a','a','a','a','a')
COL2<-c('b','b','b','b','b','b','b','b')
COL3<-c('c','c','c','c','c','c','c','c')
COL4<-c('d','d','d','d','d','d','d','d')
COL5<-c('e','e','e','e','e','e','e','e')
COL6<-c('f','f','f','f','f','f','f','f')
COL7<-c('g','g','g','g','g','g','g','g')
df<-data.frame(ID,COL1,COL2,COL3,COL4,COL5,COL6,COL7)
I want to get a column to simply merge other columns without space.
ID COL1 COL2 COL3 COL4 COL5 COL6 COL7 col1to4 col1to7 col3to5
1 1 a b c d e f g abcd abcdefg cde
2 2 a b c d e f g abcd abcdefg cde
3 3 a b c d e f g abcd abcdefg cde
4 4 a b c d e f g abcd abcdefg cde
5 5 a b c d e f g abcd abcdefg cde
6 6 a b c d e f g abcd abcdefg cde
7 7 a b c d e f g abcd abcdefg cde
8 8 a b c d e f g abcd abcdefg cde
Thanks in advance.