Skip to content

Commit

Permalink
us_temp data (to use in place of climate70)
Browse files Browse the repository at this point in the history
  • Loading branch information
hardin47 committed Oct 25, 2023
1 parent 1dbc62e commit 305cc9e
Show file tree
Hide file tree
Showing 4 changed files with 18,822 additions and 0 deletions.
47 changes: 47 additions & 0 deletions R/data-us_temp.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#' US temperatures in 1950 and 2022
#'
#' A representative set of monitoring locations were taken from NOAA
#' data in 1950 and 2022 such that the locations are sampled roughly
#' geographically across the continental US (the observations do not
#' represent a random sample of geographical locations).
#'
#' Please keep in mind that the data represent two annual snapshots, and a complete
#' analysis would consider more than two years of data and a random or more
#' complete sampling of weather stations across the US.
#'
#' @name us_temp
#' @docType data
#' @format A data frame with 18759 observations on the following 9 variables.
#' \describe{
#' \item{location}{Location of the NOAA weather station.}
#' \item{station}{Formal ID of the NOAA weather station.}
#' \item{latitude}{Latitude of the NOAA weather station.}
#' \item{longitude}{Longitude of the NOAA weather station.}
#' \item{date}{Date the measurement was taken (Y-m-d).}
#' \item{tmax}{Maximum daily temperature (Farenheit).}
#' \item{tmin}{Minimum daily temperature (Farenheit).}
#' \item{year}{Year of the measurement.}
#' }
#' @source [NOAA Climate Data Online](https://www.ncdc.noaa.gov/cdo-web/). Retrieved 23 September, 2023.
#' @keywords datasets
#' @examples
#' library(ggplot2)
#' library(sf)
#'
#' summarized_temp <- us_temp |>
#' group_by(station, year, latitude, longitude) |>
#' summarize(tmax_med = median(tmax, na.rm = TRUE)) |>
#' mutate(plot_shift = ifelse(year == "1950", 0, 1))
#'
#' usa <- st_as_sf(maps::map("state", fill = TRUE, plot = FALSE))
#' ggplot(data = usa) +
#' geom_sf() +
#' geom_point(data = summarized_temp,
#' aes(x = longitude + plot_shift, y = latitude,
#' color = tmax_med, shape = year)) +
#' scale_color_gradient(high = IMSCOL["red", 1], low = IMSCOL["yellow", 1]) +
#' ggtitle("Median of the daily high temp, 1950 & 2022") +
#' labs(x = "longitude",
#' color = "median high temp") +
#' guides(shape = guide_legend(override.aes = list(color = "black")))
"us_temp"
15 changes: 15 additions & 0 deletions data-raw/us_temp/us_temp-dataprep.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Load packages ----------------------------------------------------------------

library(openintro)
library(tidyverse)
library(usethis)
library(lubridate)

# Load data --------------------------------------------------------------------

us_temp <- read_csv("data-raw/us_temp/us_temp.csv") |>
select(location, everything())

# Add to package
use_data(us_temp, overwrite = TRUE)

Loading

0 comments on commit 305cc9e

Please sign in to comment.