Re: [R] Way to convert data frame to matrix

From: Sarah Goslee <>
Date: Sat 01 Jul 2006 - 00:33:21 EST

Hi Wade,

On 6/30/06, 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.

Try crosstab(mydata$plotID, mydata$species, mydata$cover) from the ecodist package.


Sarah Goslee

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Sat Jul 01 00:50:04 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 01 Jul 2006 - 02:14:04 EST.

Mailing list information is available at Please read the posting guide before posting to the list.