[R] presence/absence matrix

rocchini at unisi.it rocchini at unisi.it
Fri Jul 20 16:16:39 CEST 2007


I have a table such that:

sample #   species
1    a
1    b
2    a   
2    c
3    b     

and i would like to build a matrix with species names (i.e. a b and c) 
as field names and samples (i.e. 1,2 and 3) as row names
and 1/0 as inner values
such as:
    a   b   c
1   1   1   0
2   1   0   1
3   0   1   0

I am currently using Rcmdr package for managing datasets but need a 
function about.... I tried to use stack function but only with worst results

Thanks
Duccio



More information about the R-help mailing list