On 10/29/2016 11:19 AM, Elham - via R-help 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
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
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.65
> 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
>
Here's what you _should_ do
1) transpose
2a) as.data.frame
3a) fix the stupid default stringsAsFactor behavior
4a) convert the first 5 columns to numeric
dfrm <- as.data.frame( t( structure(.) ) )
dfrm[, 1:5] <-lapply(dfrm[, 1:5], as.character)
dfrm[, 1:5] <-lapply(dfrm[, 1:5], as.numeric)
Or:
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Ken
> Sent: Wednesday, August 03, 2011 12:13 PM
> To: Jeffrey Joh
> Cc:
> Subject: Re: [R] Convert matrix to numeric
>
> How about
> Matr
Hi Jeffrey,
On Wed, Aug 3, 2011 at 3:04 PM, Jeffrey Joh wrote:
>
> I have a matrix that looks like this:
>
>
> structure(c("0.0376673981759913", "0.111066500741386", "1", "1103",
> "18", "OPEN", "DEPR", "0.0404073656092023", "0.115186044704599",
> "1", "719", "18", "OPEN", "DEPR", "0.066534209669
How about
Matrix[1:5,]=as.numeric(Matrix[1:5,])
-Ken Hutchison
On Aug 3, 2554 BE, at 3:04 PM, Jeffrey Joh wrote:
>
> I have a matrix that looks like this:
>
>
> structure(c("0.0376673981759913", "0.111066500741386", "1", "1103",
> "18", "OPEN", "DEPR", "0.0404073656092023", "0.11518604470459
On 03/08/2011 3:04 PM, Jeffrey Joh wrote:
I have a matrix that looks like this:
structure(c("0.0376673981759913", "0.111066500741386", "1", "1103",
"18", "OPEN", "DEPR", "0.0404073656092023", "0.115186044704599",
"1", "719", "18", "OPEN", "DEPR", "0.0665342096693433", "0.197570061769498",
"1",
I have a matrix that looks like this:
structure(c("0.0376673981759913", "0.111066500741386", "1", "1103",
"18", "OPEN", "DEPR", "0.0404073656092023", "0.115186044704599",
"1", "719", "18", "OPEN", "DEPR", "0.0665342096693433", "0.197570061769498",
"1", "1103", "18", "OPEN", "DEPR", "0.1192871
> > The row names on a data frame should be unique. You can try
> > as.data.frame(xx, row.names=FALSE) to convert zz to be a data frame.
If
> > you need the row name information, add it as a column in the data
frame,
> > e.g. mydataframe$rnames <- rownames(zz). (Note to R-Core: the
> > document
On Mon, 20 Oct 2008, [EMAIL PROTECTED] wrote:
I have a matrix x with repeating row names.
zz<-matrix(0,4,4)
rownames(zz)=c("a","a","b","b")
data.frame(zz) (?)
The row names on a data frame should be unique. You can try
as.data.frame(xx, row.names=FALSE) to convert zz to be a data frame.
> I have a matrix x with repeating row names.
> zz<-matrix(0,4,4)
>
> rownames(zz)=c("a","a","b","b")
>
> data.frame(zz) (?)
The row names on a data frame should be unique. You can try
as.data.frame(xx, row.names=FALSE) to convert zz to be a data frame. If
you need the row name information
Hi R,
I have a matrix x with repeating row names.
> dim(x)
[1] 862 19
zz<-matrix(0,4,4)
rownames(zz)=c("a","a","b","b")
data.frame(zz) (?)
I need to use x in a linear regression
lm(as.formula(paste("final_dat[,5]~",paste(colnames(x),collapse="+"))),x
)
this gives me a error
14 matches
Mail list logo