[R] adding a named column to a Matrix

Alison Callahan alison.callahan at gmail.com
Wed Oct 13 22:44:51 CEST 2010


Hello all,

I am trying to use cbind to add a named empty column to a Matrix:

outputmatrix <- cbind(outputmatrix,kog_id = seq(0,0,0))

The problem I have is that kog_id is a variable that has a value e.g.
"KOG1234", but I when I try to use this to name the added column, it
is named literally "kog_id" instead of "KOG1234".

How can I name a column by passing in a variable for the column name?
I am performing this action inside of a for loop, so I can't
necessarily know the position of the column in order to name it after
it is created.

Thanks,

Alison Callahan
-----------------------
PhD Candidate
Department of Biology
Carleton University



More information about the R-help mailing list