[R] Convert matrix

Jim Lemon drjimlemon at gmail.com
Sun Oct 30 10:30:07 CET 2016


Hi Elham,
As you have asked this question a large number of times in quite a few
places, and have received reasonable answers, I assume that you
already know that the gene names and associated values are in another
format. What you probably want to do is to convert the first column of
the data that you have imported into rownames:

test2a<-(test2[,-1])
rownames(test2a)<-test2[,1]

Why do I guess this? Because the values in a matrix must all be of the
same data type and you probably have a data frame in which the first
column is the names. You want the numeric values in the subsequent
columns to become a matrix. Perhaps I have guessed correctly. Perhaps
not.

Jim


On Sun, Oct 30, 2016 at 3:01 AM, Elham Dallalbashi
<elhamdallalbashi at gmail.com> wrote:
>> Dear Madam / Sir,
>> I saw this function for "*Convert to matrix as it is that you wanted" *
>>
>> >* test2<-as.matrix(test1)
>> *>* colnames(test2)<-NULL
>> *>* genelist<-c("Fkh2","Swi5","Sic1")
>> *>* rownames(test2)<-genelist
>> *>* test2
>> *>* #      [,1]  [,2]  [,3]
>> *>* #Fkh2 0.141 0.242 0.342
>> *>* #Swi5 0.224 0.342 0.334
>> *>* #Sic1 0.652 0.682 0.182*
>>
>>
>>
>>
>> what is function for large data?my data and genelist are 28031 rows,how
>> can I convert? clear that I can not write 28031 genes like
>> *genelist<-c("Fkh2","Swi5","Sic1")*
>>
>>
>>
>> Your attention would be really appreciated.
>>
>> Best Regards,
>>
>> Elham Dalalbshi Esfahani
>>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list