Re: [R] convert matrix

2016-10-30 Thread Robert Baer
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

Re: [R] Convert matrix

2016-10-30 Thread Jim Lemon
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

[R] convert matrix

2016-10-29 Thread Elham - via R-help
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

Re: [R] Convert matrix

2016-10-29 Thread Elham Dallalbashi
> 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 >

Re: [R] Convert matrix to numeric

2011-08-03 Thread David Winsemius
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:

Re: [R] Convert matrix to numeric

2011-08-03 Thread Nordlund, Dan (DSHS/RDA)
> -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

Re: [R] Convert matrix to numeric

2011-08-03 Thread Sarah Goslee
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

Re: [R] Convert matrix to numeric

2011-08-03 Thread Ken
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

Re: [R] Convert matrix to numeric

2011-08-03 Thread Duncan Murdoch
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",

[R] Convert matrix to numeric

2011-08-03 Thread Jeffrey Joh
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

Re: [R] convert matrix to dataframe with repeating row names

2008-10-20 Thread Richard . Cotton
> > 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

Re: [R] convert matrix to dataframe with repeating row names

2008-10-20 Thread Prof Brian Ripley
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.

Re: [R] convert matrix to dataframe with repeating row names

2008-10-20 Thread Richard . Cotton
> 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

[R] convert matrix to dataframe with repeating row names

2008-10-20 Thread Ravi S. Shankar
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