I'm looking at some code:
df1 <- inner_join(metadata, otu_counts, by="sample_id") %>%
inner_join(., taxonomy, by="otu") %>%
group_by(sample_id) %>%
mutate(rel_abund = count / sum(count)) %>%
ungroup() %>%
select(-count)
This first chunk I completely understand but I'm new and I can only assume that this second chunk's '.group = "drop"' does the same thing as the previous ungroup().
If so, then does it have to do with the last function being a summarize() function?
df2 <- df1 %>%
filter(level=="phylum") %>%
group_by(disease_stat, sample_id, taxon) %>%
summarize(rel_abund = sum(rel_abund), .groups="drop") %>% #
group_by(disease_stat, taxon) %>%
summarize(mean_rel_abund = 100*mean(rel_abund), .groups="drop")
Can someone explain?
UPDATE: I realize that the first .groups = "drop" eliminates a newly created variable which was sample_id. Is there more to this?