[R] presence/absence matrix
Francisco J. Zagmutt
gerifalte28 at hotmail.com
Fri Jul 20 16:41:46 CEST 2007
See ?table i.e.
> x
sample # species
1 1 a
2 1 b
3 2 a
4 2 c
5 3 b
> table(x)
species
sample # a b c
1 1 1 0
2 1 0 1
3 0 1 0
Regards,
Francisco
Francisco J. Zagmutt
rocchini at unisi.it wrote:
> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list