I'm using ggplot2 to create figures and calculate summary statistics from a CSV with roughly 5,000 observations. The CSV I'm working with is structured like this:
| point | user | HUC | slope | hand | twi | classification | drainagewing |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 10194587 | 21 | 0 | 30 | active channel | small |
| 2 | 1 | 18594037 | 20 | 0 | 20 | active floodplain | small |
| 3 | 2 | 18594037 | 23 | 10 | 10 | active floodplain | small |
| 4 | 2 | 18503863 | 27 | 25 | 7 | inactive floodplain | small |
| 5 | 2 | 18503863 | 0 | 10 | 8 | definitely not valley bottom | medium |
| 6 | 6 | 18503863 | 2 | 2 | 13 | definitely not valley bottom | medium |
| 7 | 4 | 18503863 | 4 | 3 | 18 | active floodplain | medium |
| 8 | 5 | 18503863 | 10 | 6 | 2 | inactive floodplain | medium |
| 9 | 5 | 10194587 | 12 | 2 | 10 | active channel | large |
| 10 | 2 | 10194587 | 6 | 1 | 29 | active channel | large |
I want to create boxplots and calculate the summary stats for slope, twi, and hand values within small, medium, and large drainage wings -- so, essentially, 9 boxplots and 9 sets of summary stats.
For example, I started working on slope values across small, medium, and large drainage wings:
ggplot(data = vbet, mapping = aes(y = slope, x = drainagewing, fill = drainagewing)) +
geom_boxplot() +
labs(title = "Distribution of Slope by Drainage Wing Size",
x = "Drainage Wing Size",
y = "Slope",
fill = "Drainage Wing Size")

I know how to get summary stats of the whole CSV (validation.csv), but I just don't know how to break them apart like I've described above.
Bonus question-- how do I organize x-axis items? For example, the default is to organize my boxes within the plot as (Large, Medium, Small) drainage wings. How can I customize the order here?

