[R] Converting a data frame to matrix

From: Adrian Johnson <oriolebaltimore_at_gmail.com>
Date: Thu, 27 Mar 2008 20:43:22 -0400


Hello:

I have a tab delim file with 100 rows and 100 columns.

I have numerical values in this table. What I want is to create an image color map with color gradation.

my values range from -5 to 0. max value is 0.

to acheive this, I need to convert my data.frame into matrix.

I tried following :

mydf <- read.table('mytable',sep='\t',header=T) mydf1 <- mydf[,2:100]
colnames(mydf1) <- as.character(mydf[,1])

here comes the trouble:

mymat <- as.matrix(mydf1)

mymat <- data.matrix(mydf1)

Is there any other way I can do this.

say row names are city schools
colnames are student names

appreciate your help.

Thanks
AJ

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
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. Received on Fri 28 Mar 2008 - 00:47:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 28 Mar 2008 - 09:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive