This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Hide column label of genes

Dear All,

It might be a naive question, but I got stuck a bit. How could I read csv file into R and make the gene column had no label like the picture in attached. everytime I read my data in, the label is still there.

thank in advance.

regards,

synat

enter image description here

geneexpression

colnames(mat) = NULL

Dear galaxy,

thank for your response.

i have dataframe called ifn

colnames(ifn) = NULL all the columns are gone

I just need to hide one column in my dataframe, which are genes I used the following code

colnames(ifn$genes)= NULL, gene column is still there

Attached image is my dataframe

enter image description here .

Kind Regards,

Synat

1 answer

I'm going to interpret your question a bit. I'm assuming here that you just want to convert your data.frame to a matrix.

# create a matrix from the data.frame
mat2 = as.matrix(mat[,-1]) 

# add rownames to the matrix
rownames(mat2) = mat[,1] 

# show the matrix with genes as rownames
mat2

Note that if the "genes" column has duplicates, this won't work as expected since rownames must be unique.

Dear Sean,

it works perfectly. big thank for your kind help and thank to galaxy too.

Kind Regards,

synat

Log in to answer this question.