[R] presence/absence matrix
Stefano Calza
stef at biostatistics.it
Fri Jul 20 16:45:18 CEST 2007
What about
table(sample,species)
Stefano
On Fri, Jul 20, 2007 at 04:16:39PM +0200, rocchini a unisi.it wrote:
<rocchini>I have a table such that:
<rocchini>
<rocchini>sample # species
<rocchini>1 a
<rocchini>1 b
<rocchini>2 a
<rocchini>2 c
<rocchini>3 b
<rocchini>
<rocchini>and i would like to build a matrix with species names (i.e. a b and c)
<rocchini>as field names and samples (i.e. 1,2 and 3) as row names
<rocchini>and 1/0 as inner values
<rocchini>such as:
<rocchini> a b c
<rocchini>1 1 1 0
<rocchini>2 1 0 1
<rocchini>3 0 1 0
<rocchini>
<rocchini>I am currently using Rcmdr package for managing datasets but need a
<rocchini>function about.... I tried to use stack function but only with worst results
<rocchini>
<rocchini>Thanks
<rocchini>Duccio
<rocchini>
<rocchini>______________________________________________
<rocchini>R-help a stat.math.ethz.ch mailing list
<rocchini>https://stat.ethz.ch/mailman/listinfo/r-help
<rocchini>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
<rocchini>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list