[R] :How to insert a column in a data frame

Laura Rodriguez Murillo laura.lmurillo at gmail.com
Wed Feb 18 00:51:05 CET 2009


Hi dear list,

I wonder if somebody can help me with this. I have a text file with
300 rows and around 300000 columns and I need to insert a column that
has the number 1 in every row. This new column should be placed
between columns 6 and 7.

As an example: I would want to insert a column (consiting just of the
number 1 in every row, as in column 6) between columns 6 and 7.

847 847 0 0 2 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T

So the new table would look like this:

847 847 0 0 2 1 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T
847 847 0 0 2 1 1 G G T C A G T T C G A C C C G C A A A G G G G A C A T T

You can also look at this problem as duplicating column 6.

Thank you for your help!

--------------------------------
Laura R Murillo
Columbia University
New York




More information about the R-help mailing list