Skip to content

Commit

Permalink
Quarterly
Browse files Browse the repository at this point in the history
  • Loading branch information
bpbond committed Aug 2, 2024
1 parent fc109de commit 62a81ab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions synoptic/data/L1/code_examples/cumulative-observations.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ results <- separate(results, Timerange, sep = "-", into = c("Begin", "End"))
results$Date <- as.Date(results$Begin, format = "%Y%m%d")
results$Year <- year(results$Date)
results$Month <- month(results$Date)
results$Quarter <- quarter(results$Date)

# Make some graphs
library(ggplot2)
Expand All @@ -28,12 +29,12 @@ library(scales)
library(viridis)

results %>%
group_by(Site, Year, Month) %>%
group_by(Site, Year, Quarter) %>%
summarise(rows = sum(rows)) %>%
mutate(YearMonth = ymd(paste(Year, Month, "01"))) %>%
ggplot(aes(YearMonth, Site, fill = rows)) + geom_tile() +
mutate(YearMonth = ymd(paste(Year, Quarter * 3, "01"))) %>%
ggplot(aes(YearMonth, Site, fill = rows / 3)) + geom_tile() +
xlab("Time") +
scale_fill_gradient("Observations", trans = scales::log_trans(base = 10),
scale_fill_gradient("Monthly\nobservations", trans = scales::log_trans(base = 10),
labels = unit_format(unit = "M", scale = 1e-6)) ->
p
print(p)
Expand Down

0 comments on commit 62a81ab

Please sign in to comment.