0

data_me

                       TCGA-05-4244-01A-01R-1107-07 TCGA-05-4249-01A-01R-1107-07 TCGA-05-4250-01A-01R-1107-07
ENSG00000000003                         5001                         4383                         5316
                         
ENSG00000000005                          0                             0                            5
                         
ENSG00000000008                         4545                           78                           898

class(data_me) [1] "matrix" "array".
##data_me is not data.frame structure.

”ENSG*“are rownames now , i want to set "ENSG*" as a column and give it a colname "GENE_ID". does anyone know?

YiHao Chen
  • 29
  • 4

1 Answers1

0

Example data:

data(iris)
m <- as.matrix(iris)
rownames(m) <- 1:nrow(m)

Use cbind to add a new column:

g <- cbind(m, rownames(m))

Then add your new column name:

colnames(g) <- c(colnames(m), "GENE_ID")
Skaqqs
  • 4,010
  • 1
  • 7
  • 21