jclbrooks / MD_Stream_Salamanders

MIT License
0 stars 0 forks source link

Paired boxplot #1

Closed jclbrooks closed 5 years ago

jclbrooks commented 5 years ago

Is there some way to do counts~species grouped by type? without manually moving around the data in the csv? Something in dplyr?? I want to create a paired boxplot that is grouped by type. This is shown at the bottom of the Exploration_plots.R Line 246.

@djhocking

djhocking commented 5 years ago

Added to the script and pushed to github. The tagging didn't notify me. You have to assign me with the options to the right.

library(tidyr)

foo <- sal_means[4:12]

bar <- foo %>%
  ungroup() %>%
  gather(species, count, -type, -dist)

ggplot(data = bar, aes(type, count)) + geom_boxplot() + facet_wrap(~species)

ggplot(data = bar, aes(type, count)) + geom_boxplot() + facet_wrap(~species, scales = "free")

ggplot(data = bar, aes(species, count)) + geom_boxplot() + facet_wrap(~type)