Skip to content

Commit

Permalink
Merge pull request #1686 from rstudio/add-gibraltar-dataset
Browse files Browse the repository at this point in the history
Add the `gibraltar` dataset
  • Loading branch information
rich-iannone authored May 25, 2024
2 parents 4a2c7f3 + 2c0f5ca commit a86e11d
Show file tree
Hide file tree
Showing 32 changed files with 1,694 additions and 22 deletions.
60 changes: 53 additions & 7 deletions R/datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,52 @@
#'
"metro"

#' Weather conditions in Gibraltar, May 2023
#'
#' @description
#'
#' The `gibraltar` dataset has meteorological data for the Gibraltar Airport
#' Station from May 1 to May 31, 2023. Gibraltar is a British Overseas Territory
#' and city located at the southern end of the Iberian Peninsula, on the Bay of
#' Gibraltar. This weather station is located at the airport (GIB), where it's
#' at an elevation of 5 meters above mean sea level (AMSL).
#'
#' @format A tibble with 1,431 rows and 10 variables:
#' \describe{
#' \item{date, time}{The date and time of the observation.}
#' \item{temp, dew_point}{The air temperature and dew point values, both in
#' degrees Celsius.}
#' \item{humidity}{The relative humidity as a value between `0` and `1`}
#' \item{wind_dir, wind_speed, wind_gust}{Observations related to wind. The wind
#' direction is given as the typical 'blowing from' value, simplified to one of
#' 16 compass directions. The wind speed is provided in units of meters per
#' second. If there was a measurable wind gust, the maximum gust speed is
#' recorded as m/s values (otherwise the value is `0`).}
#' \item{pressure}{The atmospheric pressure in hectopascals (hPa).}
#' \item{condition}{The weather condition.}
#' }
#'
#' @section Examples:
#'
#' Here is a glimpse at the data available in `gibraltar`.
#'
#' ```{r}
#' dplyr::glimpse(gibraltar)
#' ```
#'
#' @family datasets
#' @section Dataset ID and Badge:
#' DATA-10
#'
#' \if{html}{\out{
#' `r data_get_image_tag(file = "dataset_gibraltar.png")`
#' }}
#'
#' @section Dataset Introduced:
#' *In Development*
#'
"gibraltar"

#' The fundamental physical constants
#'
#' @description
Expand Down Expand Up @@ -661,7 +707,7 @@
#'
#' @family datasets
#' @section Dataset ID and Badge:
#' DATA-10
#' DATA-11
#'
#' \if{html}{\out{
#' `r data_get_image_tag(file = "dataset_constants.png")`
Expand Down Expand Up @@ -754,7 +800,7 @@
#'
#' @family datasets
#' @section Dataset ID and Badge:
#' DATA-11
#' DATA-12
#'
#' \if{html}{\out{
#' `r data_get_image_tag(file = "dataset_illness.png")`
Expand Down Expand Up @@ -858,7 +904,7 @@
#'
#' @family datasets
#' @section Dataset ID and Badge:
#' DATA-12
#' DATA-13
#'
#' \if{html}{\out{
#' `r data_get_image_tag(file = "dataset_reactions.png")`
Expand Down Expand Up @@ -917,7 +963,7 @@
#'
#' @family datasets
#' @section Dataset ID and Badge:
#' DATA-13
#' DATA-14
#'
#' \if{html}{\out{
#' `r data_get_image_tag(file = "dataset_photolysis.png")`
Expand Down Expand Up @@ -978,7 +1024,7 @@
#'
#' @family datasets
#' @section Dataset ID and Badge:
#' DATA-14
#' DATA-15
#'
#' \if{html}{\out{
#' `r data_get_image_tag(file = "dataset_nuclides.png")`
Expand Down Expand Up @@ -1048,7 +1094,7 @@
#'
#' @family datasets
#' @section Dataset ID and Badge:
#' DATA-15
#' DATA-16
#'
#' \if{html}{\out{
#' `r data_get_image_tag(file = "dataset_rx_adsl.png")`
Expand Down Expand Up @@ -1121,7 +1167,7 @@
#'
#' @family datasets
#' @section Dataset ID and Badge:
#' DATA-16
#' DATA-17
#'
#' \if{html}{\out{
#' `r data_get_image_tag(file = "dataset_rx_addv.png")`
Expand Down
1 change: 1 addition & 0 deletions R/utils_examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ write_gt_examples_qmd_files <- function(
"towny",
"peeps",
"metro",
"gibraltar",
"constants",
"illness",
"reactions",
Expand Down
34 changes: 34 additions & 0 deletions data-raw/10-gibraltar.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library(tidyverse)

gibraltar <-
readr::read_csv(
file = "data-raw/gibraltar.csv",
col_types =
cols(
date = col_date(format = ""),
time = col_time(format = ""),
temp = col_character(),
dew_point = col_character(),
humidity = col_character(),
wind_dir = col_character(),
wind_speed = col_character(),
wind_gust = col_character(),
pressure = col_character(),
precip = col_character(),
condition = col_character()
)
) %>%
dplyr::select(-precip) %>%
dplyr::mutate(time = sub(":00$", "", as.character(time))) %>%
dplyr::mutate(temp = as.numeric(gsub("\\D", "", temp))) %>%
dplyr::mutate(dew_point = as.numeric(gsub("\\D", "", dew_point))) %>%
dplyr::mutate(humidity = as.numeric(gsub("\\D", "", humidity))) %>%
dplyr::mutate(wind_speed = as.numeric(gsub("\\D", "", wind_speed))) %>%
dplyr::mutate(wind_gust = as.numeric(gsub("\\D", "", wind_gust))) %>%
dplyr::mutate(pressure = as.numeric(gsub("[^0-9\\.]", "", pressure))) %>%
dplyr::mutate(temp = round((temp - 32) * 5/9, 1)) %>%
dplyr::mutate(dew_point = round((dew_point - 32) * 5/9, 1)) %>%
dplyr::mutate(humidity = humidity / 100) %>%
dplyr::mutate(wind_speed = round(wind_speed * 0.44704, 1)) %>%
dplyr::mutate(wind_gust = round(wind_gust * 0.44704, 1)) %>%
dplyr::mutate(pressure = round(pressure * 33.863889532610884, 1))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

4 comments on commit a86e11d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.