## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----setup, message=FALSE, warning=FALSE-------------------------------------- library(ggdibbler) library(ggplot2) library(dplyr) library(sf) library(distributional) ## ----------------------------------------------------------------------------- glimpse(toy_temp) ## ----------------------------------------------------------------------------- # Plot Raw Data ggplot(toy_temp) + geom_sf(aes(geometry=county_geometry)) + geom_jitter(aes(x=county_longitude, y=county_latitude, colour=recorded_temp), width=5000, height =5000, alpha=0.7) ## ----------------------------------------------------------------------------- # Mean data toy_temp_mean <- toy_temp |> group_by(county_name) |> summarise(temp_mean = mean(recorded_temp)) # Plot Mean Data ggplot(toy_temp_mean) + geom_sf(aes(geometry=county_geometry, fill=temp_mean)) ## ----------------------------------------------------------------------------- # Mean and variance data toy_temp_est <- toy_temp |> group_by(county_name) |> summarise(temp_mean = mean(recorded_temp), temp_se = sd(recorded_temp)/sqrt(n())) ## ----------------------------------------------------------------------------- # Distribution toy_temp_dist <- toy_temp_est |> mutate(temp_dist = dist_normal(temp_mean, temp_se)) |> select(county_name, temp_dist) # Plot Distribution Data ggplot(toy_temp_dist) + geom_sf_sample(aes(geometry=county_geometry, fill=temp_dist)) ## ----------------------------------------------------------------------------- ggplot(toy_temp_dist) + geom_sf_sample(aes(geometry = county_geometry, fill=temp_dist), linewidth=0.1) + geom_sf(aes(geometry = county_geometry), fill=NA, linewidth=1)