[R] reshape data, adding rows to dataframe

Ivan Calandra ivan.calandra at uni-hamburg.de
Wed Feb 2 11:09:26 CET 2011


Hi,

Not sure what you want to do, but take a look at ?duplicated, ?unique, 
and maybe ?aggregate; it might be what you're looking for.

HTH,
Ivan

Le 2/2/2011 10:13, Lucia Rueda a écrit :
> Hello everyone,
>
> I have a data set like this:
>
>> head( fish_transect)
>    ID_TRANSECT ID_PROJECT   DE_ZONE DE_LOCALITY DE_SECTOR MES
> 1          42         MB Tarragona    Creixell Control I   9
> 2          42         MB Tarragona    Creixell Control I   9
> 3          42         MB Tarragona    Creixell Control I   9
> 4          42         MB Tarragona    Creixell Control I   9
> 5          42         MB Tarragona    Creixell Control I   9
> 6          42         MB Tarragona    Creixell Control I   9
>                 ID_SPECIES         WEIGHT  SIZE   N    FAMILIA
> 1 Spondyliosoma cantharus    15.64     10     1    Sparidae
> 2  Symphodus melanocercus  11.21     10      1   Labridae
> 3       Diplodus vulgaris         30.20     10      2   Sparidae
> 4       Diplodus vulgaris         52.24     12      2   Sparidae
> 5         Diplodus sargus        221.41    14     5    Sparidae
> 6      Diplodus annularis         3.47       6      1    Sparidae
>
> I have been trying to duplicate the rows where N>  1, that is I want a row
> for each animal. Right now as you can see I have for example 5 D. sargus
> which are 14 cm length and so on. How can I get 1 row for each animal? I've
> been trying the reshape function without success. I also tried in access but
> couldn't do it either.
>
> Thanks a lot,
>
> Lucia
>
>
>

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php



More information about the R-help mailing list