library(dplyr)
library(ggplot2)

# Load the data
summary_slopes <- read.csv("/Users/deneyo/Downloads/summary_slopes.csv")

cera_filtered <- summary_slopes %>%
  filter(Site == "Cera", Sensor != "Air")



# Stacked bar plot for Irvine only
ggplot(
  cera_filtered,
  aes(x = Sensor, fill = wetness)
) +
  geom_bar(position = "stack") +
  scale_x_discrete(labels = c(
  "Lower" = "Downstream",
  "Middle" = "Middle Stream",
  "Upper" = "Upstream"
))

  labs(
    title = "Sensor Counts by Wetness (CERA)",
    x = "Sensor",
    y = "Count",
    fill = "Wetness"
  ) +
  theme_minimal()
## NULL
library(dplyr)
library(ggplot2)

# Load data
summary_slopes <- read.csv("/Users/deneyo/Downloads/summary_slopes.csv")

# ---- Filter data for Piney and remove Air sensor ----
piney_filtered <- summary_slopes %>%
  filter(Site == "Piney", Sensor != "Air")

# ---- Stacked bar plot ----
ggplot(
  piney_filtered,
  aes(x = Sensor, fill = wetness)
) +
  geom_bar(position = "stack") +
  scale_x_discrete(labels = c(
    "Lower"  = "Downstream",
    "Middle" = "Middle Stream",
    "Upper"  = "Upstream"
  )) +
  labs(
    title = "Sensor Counts by Wetness (Piney)",
    x = "Sensor",
    y = "Count",
    fill = "Wetness"
  ) +
  theme_minimal()

# ---- Wetness summary calculations (optional output) ----
wetness_summary <- piney_filtered %>%
  group_by(Site, Sensor) %>%
  summarize(
    wet_count = sum(wetness == "wet", na.rm = TRUE),
    total_obs = n(),
    wet_prop  = wet_count / total_obs,
    .groups = "drop"
  )

wetness_summary
## # A tibble: 3 × 5
##   Site  Sensor wet_count total_obs wet_prop
##   <chr> <chr>      <int>     <int>    <dbl>
## 1 Piney Lower         43        64    0.672
## 2 Piney Middle        55        64    0.859
## 3 Piney Upper         54        64    0.844
library(dplyr)
library(ggplot2)

# Load the data
summary_slopes <- read.csv("/Users/deneyo/Downloads/summary_slopes.csv")

irvine_filtered <- summary_slopes %>%
  filter(Site == "Irvine", Sensor != "Air")



# Stacked bar plot for Irvine only
ggplot(
  irvine_filtered,
  aes(x = Sensor, fill = wetness)
) +
  geom_bar(position = "stack") +
  scale_x_discrete(labels = c(
  "Lower" = "Downstream",
  "Middle" = "Middle Stream",
  "Upper" = "Upstream"
))

  labs(
    title = "Sensor Counts by Wetness (Irvine)",
    x = "Sensor",
    y = "Count",
    fill = "Wetness"
  ) +
  theme_minimal()
## NULL
# Load the data
summary_slopes <- read.csv("/Users/deneyo/Downloads/summary_slopes.csv")


library(dplyr)
library(ggplot2)

howardc_filtered <- summary_slopes %>%
  filter(Site == "Howard County", Sensor != "Air")

# Stacked bar plot for Irvine only
ggplot(
  howardc_filtered,
  aes(x = Sensor, fill = wetness)
) +
  geom_bar(position = "stack") +
  scale_x_discrete(labels = c(
  "Lower" = "Downstream",
  "Middle" = "Middle Stream",
  "Upper" = "Upstream"
))

  labs(
    title = "Sensor Counts by Wetness (Howard County Conservency)",
    x = "Sensor",
    y = "Count",
    fill = "Wetness"
  ) +
  theme_minimal()
## NULL