I have a data frame for fishing trawls, "Gads2"
> Gads2
> # A tibble: 3,487 x 4
> # Groups: Date, Time [1,741]
> Date Time Species Abundance
> <date> <time> <chr> <dbl>
> 1 1988-10-10 12:33 Gadus morhua 84
> 2 1988-10-10 12:33 Merlangius merlangus 240
> 3 1988-10-10 12:33 Trisopterus luscus 532
> 4 1988-10-10 12:33 Trisopterus minutus 540
> 5 1988-10-10 14:36 Gadus morhua 4
> 6 1988-10-10 14:36 Trisopterus minutus 140
> 7 1988-10-10 16:37 Gadus morhua 100
> 8 1988-10-10 16:37 Merlangius merlangus 16
> 9 1988-10-10 16:37 Pollachius pollachius 4
> 10 1988-10-10 16:37 Trisopterus luscus 808
> # … with 3,477 more rows
I want to group rows where date and time are equal (named Trawl 1, Trawl 2, etc.). But I have multiple species needed to be grouped within each row.
I need to combine each species and their abundance into a separate column in order to achieve this. So I tried the reshape2 package, based on what I read:
dcast(Gads2, Species ~ Abundance)
'Using Abundance as value column: use value.var to override.
Aggregation function missing: defaulting to length'
That did not work. I knew it was too simple a solution!
So I need help making each species into a new column, and then grouping by row where date and time are equal.