I have to join two data frames.:
NewGads
# A tibble: 1,740 x 7
# Groups: Date, Time [1,740]
Date Time Gadus.morhua Merlangius.merl… Trisopterus.lus…
<date> <tim> <dbl> <dbl> <dbl>
1 1988-10-10 12:33 84 240 532
2 1988-10-10 14:36 4 0 0
3 1988-10-10 16:37 100 16 808
4 1988-10-11 08:03 13 22 257
5 1988-10-11 09:03 36 104 620
6 1988-10-11 10:20 0 928 456
7 1988-10-11 12:43 8 312 0
8 1988-10-11 13:22 32 1051 0
9 1988-10-11 14:58 3 6 0
10 1988-10-12 09:28 2 2 0
# … with 1,730 more rows, and 2 more variables: Trisopterus.minutus <dbl>,
# Pollachius.pollachius <dbl>
Rays2_wide
# A tibble: 941 x 3
# Groups: Date, Time [941]
Date Time Raja.clavata
<date> <time> <dbl>
1 1988-10-10 12:33 4
2 1988-10-10 16:37 24
3 1988-10-11 08:03 6
4 1988-10-11 09:03 4
5 1988-10-11 10:20 4
6 1988-10-11 12:43 8
7 1988-10-13 07:22 8
8 1988-10-16 17:32 12
9 1988-10-17 07:59 2
10 1988-10-17 13:35 6
# … with 931 more rows
The dates and the times are the same, but there are some absences for Raja.clavata which I want to be NA's. However, they're not joining together properly with rbind.
Instead of grouping all the same dates together, it repeats the list of dates and times again at the end of the first data frame. It gives NA values for all of Raja.Clavata before repeating the dates again, where it then gives NA values for all the other species.
Why are the same dates and times not grouping together? I tried group_by as well and that didn't change anything.
OhBoy <- rbind(NewGads, Rays2_wide)
OhBoy <- OhBoy %>%
group_by(Date, Time)