fish497-2018 / Jarvis_ReefFish

0 stars 0 forks source link

Using Tidyr Functions #9

Closed raegan13 closed 6 years ago

raegan13 commented 6 years ago

Hi! I'm still encountering issues with trying to use Tidyr to manipulate my data. I think we discussed using spread(), so I'm attempting to spread my condensed dataset by Genus, but I just turn up with a lot of NAs. Is there a better way to use Tidyr to manipulate my data?

sr320 commented 6 years ago

what about this? some of it might be superfluous but you could tweak.

reef_fish %>%
  gather(`Museum.Bootless`, `Bootless`, key = "location", value = "catch_code") %>%
  select(Family, Genus, species,location, catch_code, length..cm.) %>%
  filter(catch_code == 1) %>%
  group_by(Family, location) %>%
  summarise(total_catch = sum(catch_code))
raegan13 commented 6 years ago

Thank you so much! This worked really well. In fact, displaying my data this way, I fixed up all my code and thereby fixed the issue I was having with my graphs!