[R] Way to convert data frame to matrix

Philipp Pagel philipp.pagel.lists at t-online.de
Fri Jun 30 16:32:43 CEST 2006


On Fri, Jun 30, 2006 at 10:11:15AM -0400, Wade Wall wrote:
>   I have a text file that I have imported into R.  It contains 3 columns and
> 316940 rows.  The first column is vegetation plot ID, the second species
> names and the third is a cover value (numeric).  I imported using the
> read.table function.
> 
> My problem is this.  I need to reformat the information as a matrix, with
> the first column becoming the row labels and the second the column labels
> and the cover values as the matrix cell data.

I'm not 100% sure but I think you are looking for reshape().

cu
	Philipp

-- 
Dr. Philipp Pagel                            Tel.  +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics      Fax.  +49-8161-71 2186
Technical University of Munich
Science Center Weihenstephan
85350 Freising, Germany

 and

Institute for Bioinformatics / MIPS          Tel.  +49-89-3187 3675
GSF - National Research Center               Fax.  +49-89-3187 3585
      for Environment and Health
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel



More information about the R-help mailing list