[R] variables - data-structure

Douglas Bates bates at stat.wisc.edu
Sat Dec 18 14:54:51 CET 2004


Helmut Kudrnovsky wrote:
> 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

It appears that you want to form a crosstabulation.  If so, you can use 
the table or xtabs functions.  I suggest you look at the documentation 
and examples of those and see if they will be suitable.




More information about the R-help mailing list