[R] variables - data-structure
Gabor Grothendieck
ggrothendieck at myway.com
Sat Dec 18 19:53:48 CET 2004
Helmut Kudrnovsky <hellik <at> web.de> writes:
:
: dear R-friends,
:
: i`ve got a large dataset of vegetation-samples with about 500
: variables(=species) in the following format:
:
: 1 spec1
: 1 spec23
: 1 spec54
: 1 spec63
: 2 spec1
: 2 spec2
: 2 spec253
: 2 spec300
: 2 spec423
: 3 spec20
: 3 spec88
: 3 spec121
: 3 spec200
: 3 spec450
: .
: .
:
: this means: sample 1 (grassland) with the species (=spec) 1, 23, 54, 63
:
: is it possible to get a following data-structure for further analysis?
:
: 1 2 3 ......
: spec1 1 1 0
: spec2 0 1 0
: spec3
: ...
: spec253 0 1 0
: ...
: spec450 0 0 1
:
: with thanks from the snowy tirol
: helli
If your intention is to use this as a community matrix with the R
vegan package then I think you require the transpose of the above,
namely (assuming DF contains your data frame):
comm <- with(DF, table(sample, species))
library(vegan)
diversity(comm)
specaccum(comm, method = "random")
etc.
More information about the R-help
mailing list