[R] Creating a large matrix

Des Callaghan descall at firenet.uk.net
Sun Jun 5 16:44:42 CEST 2005


Dear all,

I have a set of data that is 2 columns wide and 35,000 rows long (see
extract below).  The first column contains codes for tetrads (2km x 2km
squares within NW England) and the second column has the names of moss
species present within each tetrad.  I wish to convert this into a matrix
where rows are labelled by 'Tetrad', columns are labelled by 'Moss species'
and each cell contains a 1 or 0 to denote the presence or absence of the
moss species within each tetrad.  This would be a matrix measuring 796 rows
by 417 columns.  Am I able to do this within R?  I ran into problems trying
to do it using the crosstab query in MS Access and the pivot table function
on MS Excel because there are too many columns for these software to handle.
Thanks very much in advance for any help.

All the best,
Des

Tetrad	Moss species
SD20S	Amblystegium serpens var. serpens
SD20S	Barbula convoluta
SD21S	Brachythecium albicans
SD20J	Brachythecium rutabulum
SD30S	Bryum argenteum
SD20S	Bryum capillare




More information about the R-help mailing list