diff --git a/DESCRIPTION b/DESCRIPTION index c24892a..33aa8ea 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: weathercan Type: Package Title: Download Weather Data from Environment and Climate Change Canada -Version: 0.7.1.9000 +Version: 0.7.2 Authors@R: c( person("Steffi", "LaZerte", email = "sel@steffilazerte.ca", role = c("aut","cre"), comment = c(ORCID = "0000-0002-7690-8360")), person("Sam", "Albers", email = "sam.albers@gmail.com", role = c("ctb"), comment = c(ORCID = "0000-0002-9270-7884")), @@ -18,7 +18,7 @@ Language: en-CA BugReports: https://github.com/ropensci/weathercan/issues/ LazyData: TRUE URL: https://docs.ropensci.org/weathercan/, https://github.com/ropensci/weathercan/ -Depends: R (>= 3.3.0) +Depends: R (>= 4.1.0) Imports: dplyr (>= 1.0.0), httr (>= 1.4.2), @@ -35,7 +35,7 @@ Imports: tidyselect (>= 1.0.0), xml2 (>= 0.1.2), rappdirs (>= 0.3.3) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Roxygen: list(markdown = TRUE) Suggests: devtools, diff --git a/NAMESPACE b/NAMESPACE index 49a6fad..126115f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,3 +10,4 @@ export(weather_dl) export(weather_interp) importFrom(dplyr,"%>%") importFrom(rlang,.data) +importFrom(rlang,.env) diff --git a/R/sysdata.rda b/R/sysdata.rda index 292d68b..3ffddf5 100755 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/R/weathercan-pkg.R b/R/weathercan-package.R similarity index 65% rename from R/weathercan-pkg.R rename to R/weathercan-package.R index 60df735..08109e0 100644 --- a/R/weathercan-pkg.R +++ b/R/weathercan-package.R @@ -33,21 +33,18 @@ #' - [`kamloops_day`] #' - [`pg`] #' -#' As well as several vignettes: +#' As well as several vignettes available in the package and [Online](https://docs.ropensci.org/weathercan/): #' -#' - General Usage: `vignette("usage")` -#' - Merging and Interpolating: `vignette("interpolation")` -#' - Flags and Codes: `vignette("flags")` -#' - Weather Data Glossary: `vignette("glossary")` -#' - Climate Normals Glossary: `vignette("glossary_normals")` +#' - [General Usage](https://docs.ropensci.org/weathercan/articles/weathercan.html): `vignette("weathercan", package = "weathercan")` +#' - [Interpolating](https://docs.ropensci.org/weathercan/articles/interpolate_data.html): `vignette("interpolation", package = "weathercan")` +#' - [Reproducibility](https://docs.ropensci.org/weathercan/articles/reproducibility.html): `vignette("reproducibility", package = "weathercan")` +#' - [Flags and Codes](https://docs.ropensci.org/weathercan/articles/flags.html): `vignette("flags", package = "weathercan")` +#' - [Weather: Terms and Units](https://docs.ropensci.org/weathercan/articles/glossary.html): `vignette("glossary", package = "weathercan")` +#' - [Climate Normals: Terms and Units](https://docs.ropensci.org/weathercan/articles/glossary_normals.html): `vignette("glossary_normals", package = "weathercan")` #' -#' [Online](https://docs.ropensci.org/weathercan/) we also have some -#' advanced articles: +#' We also have some advanced articles: #' -#' - Using `weathercan` with [tidyverse](https://www.tidyverse.org/) -#' ([here](https://docs.ropensci.org/weathercan/articles/articles/use_with_tidyverse.html)) -#' - Mapping weather data -#' ([here](https://docs.ropensci.org/weathercan/articles/articles/mapping.html)) +#' - [Using `weathercan` with tidyhydat](https://docs.ropensci.org/weathercan/articles/tidyhydat.html)) #' #' @references #' Environment and Climate Change Canada: @@ -57,12 +54,10 @@ #' ECCC Historical Climate Data: #' #' -#' @docType package -#' @name weathercan-package -#' @aliases weathercan weathercan-package +#' @keywords internal +"_PACKAGE" #' @importFrom dplyr "%>%" -#' @importFrom rlang .data - +#' @importFrom rlang .data .env NULL # Dealing with CRAN Notes due to Non-standard evaluation @@ -85,7 +80,6 @@ NULL "https://climate.weather.gc.ca/climate_normals/station_inventory_e.html", weathercan.time.message = FALSE) - # CRAN Note avoidance if(getRversion() >= "2.15.1") utils::globalVariables( @@ -96,3 +90,9 @@ NULL ) invisible() } + +.onAttach <- function(libname, pkgname) { + packageStartupMessage( + "As of v0.7.2, the `normals` column in `stations()` reflects whether or not ", + "there\nare *any* normals available (not just the most recent).") +} diff --git a/README.Rmd b/README.Rmd index 413797b..01011b7 100755 --- a/README.Rmd +++ b/README.Rmd @@ -34,7 +34,7 @@ For more details and tutorials checkout the [weathercan website](https://docs.ro ## Installation -You can install `weathercan` from the [rOpenSci r-Universe](https://ropensci.r-universe.dev/ui/): +You can install `weathercan` from the [rOpenSci r-Universe](https://ropensci.r-universe.dev/): ```{r, eval = FALSE} install.packages("weathercan", diff --git a/README.md b/README.md index 59dd352..bcb9308 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ docs](http://ropensci.github.io/weathercan/)) ## Installation You can install `weathercan` from the [rOpenSci -r-Universe](https://ropensci.r-universe.dev/ui/): +r-Universe](https://ropensci.r-universe.dev/): ``` r install.packages("weathercan", @@ -61,22 +61,23 @@ stations and their details (including `station_id`). head(stations()) ``` - ## # A tibble: 6 × 16 - ## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz interval start end normals normals_1981_2010 normals_1971_2000 + ## # A tibble: 6 × 17 + ## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz interval start end normals normals_1991_2020 normals_1981_2010 ## ## 1 AB DAYSLAND 1795 301AR54 NA 52.9 -112. 689. Etc/GMT+7 day 1908 1922 FALSE FALSE FALSE ## 2 AB DAYSLAND 1795 301AR54 NA 52.9 -112. 689. Etc/GMT+7 hour NA NA FALSE FALSE FALSE ## 3 AB DAYSLAND 1795 301AR54 NA 52.9 -112. 689. Etc/GMT+7 month 1908 1922 FALSE FALSE FALSE ## 4 AB EDMONTON CORONATION 1796 301BK03 NA 53.6 -114. 671. Etc/GMT+7 day 1978 1979 FALSE FALSE FALSE ## 5 AB EDMONTON CORONATION 1796 301BK03 NA 53.6 -114. 671. Etc/GMT+7 hour NA NA FALSE FALSE FALSE - ## 6 AB EDMONTON CORONATION 1796 301BK03 NA 53.6 -114. 671. Etc/GMT+7 month 1978 1979 FALSE FALSE FALSE + ## 6 AB EDMONTON CORONATION 1796 301BK03 NA 53.6 -114. 671. Etc/GMT+7 month 1978 1979 FALSE FALSE FALSE + ## # ℹ 1 more variable: normals_1971_2000 ``` r glimpse(stations()) ``` ## Rows: 26,382 - ## Columns: 16 + ## Columns: 17 ## $ prov "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", "AB", … ## $ station_name "DAYSLAND", "DAYSLAND", "DAYSLAND", "EDMONTON CORONATION", "EDMONTON CORONATION", "EDMONTON CORONATION", "FLEET", "FLEET", "FLEET", … ## $ station_id 1795, 1795, 1795, 1796, 1796, 1796, 1797, 1797, 1797, 1798, 1798, 1798, 1799, 1799, 1799, 1800, 1800, 1800, 1801, 1801, 1801, 1802, … @@ -91,6 +92,7 @@ glimpse(stations()) ## $ start 1908, NA, 1908, 1978, NA, 1978, 1987, NA, 1987, 1987, NA, 1987, 1980, NA, 1980, 1980, NA, 1980, 1986, NA, 1986, 1987, NA, 1987, 1986… ## $ end 1922, NA, 1922, 1979, NA, 1979, 1990, NA, 1990, 1998, NA, 1998, 2009, NA, 2007, 1981, NA, 1981, 2019, NA, 2007, 1991, NA, 1991, 1995… ## $ normals FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRU… + ## $ normals_1991_2020 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,… ## $ normals_1981_2010 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRU… ## $ normals_1971_2000 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,… @@ -101,12 +103,13 @@ You can look through this data frame directly, or you can use the stations_search("Kamloops", interval = "hour") ``` - ## # A tibble: 3 × 16 - ## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz interval start end normals normals_1981_2010 normals_1971_2000 + ## # A tibble: 3 × 17 + ## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz interval start end normals normals_1991_2020 normals_1981_2010 ## ## 1 BC KAMLOOPS A 1275 1163780 71887 YKA 50.7 -120. 345. Etc/GMT+8 hour 1953 2013 TRUE TRUE TRUE - ## 2 BC KAMLOOPS A 51423 1163781 71887 YKA 50.7 -120. 345. Etc/GMT+8 hour 2013 2023 FALSE FALSE FALSE - ## 3 BC KAMLOOPS AUT 42203 1163842 71741 ZKA 50.7 -120. 345 Etc/GMT+8 hour 2006 2023 FALSE FALSE FALSE + ## 2 BC KAMLOOPS A 51423 1163781 71887 YKA 50.7 -120. 345. Etc/GMT+8 hour 2013 2023 TRUE TRUE FALSE + ## 3 BC KAMLOOPS AUT 42203 1163842 71741 ZKA 50.7 -120. 345 Etc/GMT+8 hour 2006 2023 TRUE TRUE FALSE + ## # ℹ 1 more variable: normals_1971_2000 Time frame must be one of “hour”, “day”, or “month”. @@ -116,12 +119,13 @@ You can also search by proximity: stations_search(coords = c(50.667492, -120.329049), dist = 20, interval = "hour") ``` - ## # A tibble: 3 × 17 - ## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz interval start end normals normals_1981_2010 normals_1971_2000 distance - ## - ## 1 BC KAMLOOPS A 1275 1163780 71887 YKA 50.7 -120. 345. Etc/GMT+8 hour 1953 2013 TRUE TRUE TRUE 8.61 - ## 2 BC KAMLOOPS AUT 42203 1163842 71741 ZKA 50.7 -120. 345 Etc/GMT+8 hour 2006 2023 FALSE FALSE FALSE 8.61 - ## 3 BC KAMLOOPS A 51423 1163781 71887 YKA 50.7 -120. 345. Etc/GMT+8 hour 2013 2023 FALSE FALSE FALSE 9.26 + ## # A tibble: 3 × 18 + ## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz interval start end normals normals_1991_2020 normals_1981_2010 + ## + ## 1 BC KAMLOOPS A 1275 1163780 71887 YKA 50.7 -120. 345. Etc/GMT+8 hour 1953 2013 TRUE TRUE TRUE + ## 2 BC KAMLOOPS AUT 42203 1163842 71741 ZKA 50.7 -120. 345 Etc/GMT+8 hour 2006 2023 TRUE TRUE FALSE + ## 3 BC KAMLOOPS A 51423 1163781 71887 YKA 50.7 -120. 345. Etc/GMT+8 hour 2013 2023 TRUE TRUE FALSE + ## # ℹ 2 more variables: normals_1971_2000 , distance You can update this list of stations with @@ -148,7 +152,7 @@ stations_meta() ## [1] "2023-01-24 23:30:00 UTC" ## ## $weathercan_modified - ## [1] "2023-09-20" + ## [1] "2024-11-12" **Note:** For reproducibility, if you are using the stations list to gather your data, it can be a good idea to take note of the ECCC date of @@ -200,10 +204,13 @@ associated with the station you’re interested in. stations_search("Winnipeg", normals_years = "current") ``` - ## # A tibble: 1 × 13 - ## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz normals normals_1981_2010 normals_1971_2000 - ## - ## 1 MB WINNIPEG RICHARDSON INT'L A 3698 5023222 71852 YWG 49.9 -97.2 239. Etc/GMT+6 TRUE TRUE TRUE + ## # A tibble: 4 × 14 + ## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz normals normals_1991_2020 normals_1981_2010 normals_1971_2000 + ## + ## 1 MB WINNIPEG A CS 27174 502S001 71849 XWG 49.9 -97.2 239. Etc/GMT+6 TRUE TRUE FALSE FALSE + ## 2 MB WINNIPEG INTL A 51097 5023227 NA YWG 49.9 -97.2 239. Etc/GMT+6 TRUE TRUE FALSE FALSE + ## 3 MB WINNIPEG RICHARDSON AWOS 47407 5023226 71852 YWG 49.9 -97.2 239. Etc/GMT+6 TRUE TRUE FALSE FALSE + ## 4 MB WINNIPEG RICHARDSON INT'L A 3698 5023222 71852 YWG 49.9 -97.2 239. Etc/GMT+6 TRUE TRUE TRUE TRUE Then you can download the climate normals with the `normals_dl()` function. diff --git a/codemeta.json b/codemeta.json index 8340ffd..bfa3890 100644 --- a/codemeta.json +++ b/codemeta.json @@ -1,28 +1,26 @@ { - "@context": [ - "http://purl.org/codemeta/2.0", - "http://schema.org" - ], + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", "@type": "SoftwareSourceCode", "identifier": "weathercan", - "description": "Provides means for downloading historical weather data from \n the Environment and Climate Change Canada website \n (). \n Data can be downloaded from multiple stations and over large date ranges \n and automatically processed into a single dataset. Tools are also provided \n to identify stations either by name or proximity to a location.", + "description": "Provides means for downloading historical weather data from the Environment and Climate Change Canada website (). Data can be downloaded from multiple stations and over large date ranges and automatically processed into a single dataset. Tools are also provided to identify stations either by name or proximity to a location.", "name": "weathercan: Download Weather Data from Environment and Climate Change Canada", + "relatedLink": "https://docs.ropensci.org/weathercan/", "codeRepository": "https://github.com/ropensci/weathercan/", "issueTracker": "https://github.com/ropensci/weathercan/issues/", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "0.6.2", + "version": "0.7.2", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.1.2 (2021-11-01)", + "runtimePlatform": "R version 4.4.0 (2024-04-24)", "author": [ { "@type": "Person", "givenName": "Steffi", "familyName": "LaZerte", - "email": "steffi@steffi.ca", + "email": "sel@steffilazerte.ca", "@id": "https://orcid.org/0000-0002-7690-8360" } ], @@ -54,7 +52,7 @@ "@type": "Person", "givenName": "Steffi", "familyName": "LaZerte", - "email": "steffi@steffi.ca", + "email": "sel@steffilazerte.ca", "@id": "https://orcid.org/0000-0002-7690-8360" } ], @@ -181,50 +179,51 @@ }, { "@type": "SoftwareApplication", - "identifier": "sp", - "name": "sp", + "identifier": "testthat", + "name": "testthat", + "version": ">= 3.0.0", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "sameAs": "https://CRAN.R-project.org/package=sp" + "sameAs": "https://CRAN.R-project.org/package=testthat" }, { "@type": "SoftwareApplication", - "identifier": "testthat", - "name": "testthat", + "identifier": "vcr", + "name": "vcr", + "version": ">= 1.0.2", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "sameAs": "https://CRAN.R-project.org/package=testthat" + "sameAs": "https://CRAN.R-project.org/package=vcr" }, { "@type": "SoftwareApplication", - "identifier": "vcr", - "name": "vcr", - "version": ">= 1.0.2", + "identifier": "withr", + "name": "withr", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "sameAs": "https://CRAN.R-project.org/package=vcr" + "sameAs": "https://CRAN.R-project.org/package=withr" } ], - "softwareRequirements": [ - { + "softwareRequirements": { + "1": { "@type": "SoftwareApplication", "identifier": "R", "name": "R", - "version": ">= 3.3.0" + "version": ">= 4.1.0" }, - { + "2": { "@type": "SoftwareApplication", "identifier": "dplyr", "name": "dplyr", @@ -237,7 +236,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=dplyr" }, - { + "3": { "@type": "SoftwareApplication", "identifier": "httr", "name": "httr", @@ -250,7 +249,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=httr" }, - { + "4": { "@type": "SoftwareApplication", "identifier": "lubridate", "name": "lubridate", @@ -263,7 +262,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=lubridate" }, - { + "5": { "@type": "SoftwareApplication", "identifier": "memoise", "name": "memoise", @@ -276,13 +275,13 @@ }, "sameAs": "https://CRAN.R-project.org/package=memoise" }, - { + "6": { "@type": "SoftwareApplication", "identifier": "methods", "name": "methods", "version": ">= 3.2.2" }, - { + "7": { "@type": "SoftwareApplication", "identifier": "purrr", "name": "purrr", @@ -295,7 +294,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=purrr" }, - { + "8": { "@type": "SoftwareApplication", "identifier": "rlang", "name": "rlang", @@ -308,7 +307,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=rlang" }, - { + "9": { "@type": "SoftwareApplication", "identifier": "readr", "name": "readr", @@ -321,7 +320,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=readr" }, - { + "10": { "@type": "SoftwareApplication", "identifier": "rvest", "name": "rvest", @@ -334,7 +333,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=rvest" }, - { + "11": { "@type": "SoftwareApplication", "identifier": "stringi", "name": "stringi", @@ -347,7 +346,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=stringi" }, - { + "12": { "@type": "SoftwareApplication", "identifier": "stringr", "name": "stringr", @@ -360,7 +359,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=stringr" }, - { + "13": { "@type": "SoftwareApplication", "identifier": "tidyr", "name": "tidyr", @@ -373,7 +372,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=tidyr" }, - { + "14": { "@type": "SoftwareApplication", "identifier": "tidyselect", "name": "tidyselect", @@ -386,7 +385,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=tidyselect" }, - { + "15": { "@type": "SoftwareApplication", "identifier": "xml2", "name": "xml2", @@ -399,7 +398,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=xml2" }, - { + "16": { "@type": "SoftwareApplication", "identifier": "rappdirs", "name": "rappdirs", @@ -411,11 +410,10 @@ "url": "https://cran.r-project.org" }, "sameAs": "https://CRAN.R-project.org/package=rappdirs" - } - ], - "releaseNotes": "https://github.com/ropensci/weathercan/blob/main/NEWS.md", - "readme": "https://github.com/ropensci/weathercan/blob/main/README.md", - "contIntegration": "https://app.codecov.io/gh/ropensci/weathercan", + }, + "SystemRequirements": null + }, + "fileSize": "11844.435KB", "citation": [ { "@type": "ScholarlyArticle", @@ -447,32 +445,13 @@ } } ], - "provider": { - "@id": "https://cran.r-project.org", - "@type": "Organization", - "name": "Comprehensive R Archive Network (CRAN)", - "url": "https://cran.r-project.org" - }, + "releaseNotes": "https://github.com/ropensci/weathercan/blob/master/NEWS.md", + "readme": "https://github.com/ropensci/weathercan/blob/main/README.md", + "contIntegration": ["https://github.com/ropensci/weathercan/actions", "https://app.codecov.io/gh/ropensci/weathercan"], "review": { "@type": "Review", "url": "https://github.com/ropensci/software-review/issues/160", "provider": "https://ropensci.org" }, - "keywords": [ - "weather-data", - "environment-canada", - "weather-downloader", - "r", - "rstats", - "r-package", - "peer-reviewed" - ], - "relatedLink": [ - "https://CRAN.R-project.org/package=weathercan", - "https://docs.ropensci.org/weathercan", - "https://docs.ropensci.org/weathercan/" - ], - "copyrightHolder": {}, - "funder": {}, - "fileSize": "11280.82KB" + "keywords": ["weather-data", "environment-canada", "weather-downloader", "r", "rstats", "r-package", "peer-reviewed"] } diff --git a/inst/CITATION b/inst/CITATION index dbfb8b5..18ed7f3 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -1,7 +1,7 @@ citHeader("To cite 'weathercan' in publications, please use:") -citEntry(entry = "article", +bibentry(bibtype = "Article", title = "{weathercan}: {D}ownload and format weather data from Environment and Climate Change Canada", author = c(person("Stefanie E", "LaZerte"), person("Sam", "Albers")), diff --git a/inst/extdata/stations.rds b/inst/extdata/stations.rds index 5ba6de2..4037b34 100644 Binary files a/inst/extdata/stations.rds and b/inst/extdata/stations.rds differ diff --git a/man/normals_dl.Rd b/man/normals_dl.Rd index 7537c3e..0760487 100644 --- a/man/normals_dl.Rd +++ b/man/normals_dl.Rd @@ -20,7 +20,9 @@ data frame or the \code{\link{stations_search}} function to find Climate IDs.} \item{normals_years}{Character. The year range for which you want climate -normals. Default "1981-2010".} +normals. Default "1981-2010". One of "1971-2000", "1981-2010", "1991-2020". +Note: Some "1991-2020" are available online, but are not yet downloadable +via weathercan.} \item{format}{Logical. If TRUE (default) formats measurements to numeric and date accordingly. Unlike \code{weather_dl()}, \code{normals_dl()} will always format @@ -57,9 +59,11 @@ The data also returns a column called \code{meets_wmo} this reflects whether or not the climate normals for this station met the WMO standards for temperature and precipitation (i.e. both have code >= A). Each measurement column has a corresponding \verb{_code} column which reflects the data quality -of that measurement (see the \href{https://climate.weather.gc.ca/doc/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf}{1981-2010 ECCC calculations document} -or the \href{https://climate.weather.gc.ca/doc/Canadian_Climate_Normals_1971_2000_Calculation_Information.pdf}{1971-2000 ECCC calculations document} -for more details) +of that measurement (see the +\href{https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1991_2020_Calculation_Information.pdf}{1991-2020}, +\href{https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf}{1981-2010}, or +\href{https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1971_2000_Calculation_Information.pdf}{1971-2000} +for more details) ECCC calculation documents. Climate normals are downloaded from the url stored in option \code{weathercan.urls.normals}. To change this location use: diff --git a/man/stations.Rd b/man/stations.Rd index 925d39c..2377cb1 100755 --- a/man/stations.Rd +++ b/man/stations.Rd @@ -20,9 +20,10 @@ downloading station data.} \item{interval}{Interval of the data measurements ('hour', 'day', 'month')} \item{start}{Starting year of data record} \item{end}{Ending year of data record} -\item{normals}{Whether current climate normals are available for that station} +\item{normals}{Whether \emph{any} climate normals are available for that station (new behaivour)} +\item{normals_1991_2020}{Whether 1991-2020 climate normals are available for that station. \strong{Note} that even if available, these are not yet downloadable via weathercan.} \item{normals_1981_2010}{Whether 1981-2010 climate normals are available for that station} -\item{normals_1971_2000}{Whether 1981-2010 climate normals are available for that station} +\item{normals_1971_2000}{Whether 1971-2000 climate normals are available for that station} } } \source{ diff --git a/man/weathercan-package.Rd b/man/weathercan-package.Rd index a965c76..20b1e7d 100644 --- a/man/weathercan-package.Rd +++ b/man/weathercan-package.Rd @@ -1,9 +1,9 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/weathercan-pkg.R +% Please edit documentation in R/weathercan-package.R \docType{package} \name{weathercan-package} -\alias{weathercan-package} \alias{weathercan} +\alias{weathercan-package} \title{Easy downloading of weather data from Environment and Climate Change Canada} \description{ \code{weathercan} is an R package for simplifying the downloading of @@ -51,22 +51,19 @@ We also include several practice data sets: \item \code{\link{pg}} } -As well as several vignettes: +As well as several vignettes available in the package and \href{https://docs.ropensci.org/weathercan/}{Online}: \itemize{ -\item General Usage: \code{vignette("usage")} -\item Merging and Interpolating: \code{vignette("interpolation")} -\item Flags and Codes: \code{vignette("flags")} -\item Weather Data Glossary: \code{vignette("glossary")} -\item Climate Normals Glossary: \code{vignette("glossary_normals")} +\item \href{https://docs.ropensci.org/weathercan/articles/weathercan.html}{General Usage}: \code{vignette("weathercan", package = "weathercan")} +\item \href{https://docs.ropensci.org/weathercan/articles/interpolate_data.html}{Interpolating}: \code{vignette("interpolation", package = "weathercan")} +\item \href{https://docs.ropensci.org/weathercan/articles/reproducibility.html}{Reproducibility}: \code{vignette("reproducibility", package = "weathercan")} +\item \href{https://docs.ropensci.org/weathercan/articles/flags.html}{Flags and Codes}: \code{vignette("flags", package = "weathercan")} +\item \href{https://docs.ropensci.org/weathercan/articles/glossary.html}{Weather: Terms and Units}: \code{vignette("glossary", package = "weathercan")} +\item \href{https://docs.ropensci.org/weathercan/articles/glossary_normals.html}{Climate Normals: Terms and Units}: \code{vignette("glossary_normals", package = "weathercan")} } -\href{https://docs.ropensci.org/weathercan/}{Online} we also have some -advanced articles: +We also have some advanced articles: \itemize{ -\item Using \code{weathercan} with \href{https://www.tidyverse.org/}{tidyverse} -(\href{https://docs.ropensci.org/weathercan/articles/articles/use_with_tidyverse.html}{here}) -\item Mapping weather data -(\href{https://docs.ropensci.org/weathercan/articles/articles/mapping.html}{here}) +\item \href{https://docs.ropensci.org/weathercan/articles/tidyhydat.html}{Using \code{weathercan} with tidyhydat}) } } \references{ @@ -76,3 +73,24 @@ Glossary of terms \url{https://climate.weather.gc.ca/glossary_e.html} ECCC Historical Climate Data: \url{https://climate.weather.gc.ca/} } +\seealso{ +Useful links: +\itemize{ + \item \url{https://docs.ropensci.org/weathercan/} + \item \url{https://github.com/ropensci/weathercan/} + \item Report bugs at \url{https://github.com/ropensci/weathercan/issues/} +} + +} +\author{ +\strong{Maintainer}: Steffi LaZerte \email{sel@steffilazerte.ca} (\href{https://orcid.org/0000-0002-7690-8360}{ORCID}) + +Other contributors: +\itemize{ + \item Sam Albers \email{sam.albers@gmail.com} (\href{https://orcid.org/0000-0002-9270-7884}{ORCID}) [contributor] + \item Nick Brown \email{nicholas512@gmail.com} (\href{https://orcid.org/0000-0002-2719-0671}{ORCID}) [contributor] + \item Kevin Cazelles \email{kevin.cazelles@gmail.com} (\href{https://orcid.org/0000-0001-6619-9874}{ORCID}) [contributor] +} + +} +\keyword{internal} diff --git a/release_script.R b/release_script.R index f240b50..3b953b8 100644 --- a/release_script.R +++ b/release_script.R @@ -1,17 +1,15 @@ # Steps/Commands to run before a CRAN release ----------------------------- -version <- "0.7.0" -#usethis::use_release_issue(version = v) - - -# Good practices -------------------- -goodpractice::gp() +version <- "0.7.2" +#usethis::use_release_issue(version = version) +gert::git_pull() +urlchecker::url_check() ## Update dependencies update(remotes::package_deps("weathercan", dependencies = TRUE)) -## Internal data files +## Update internal data files source("data-raw/data-index.R") source("data-raw/data-raw.R") source("data-raw/metadata.R") @@ -19,39 +17,36 @@ source("data-raw/metadata.R") ## Documentation # Update NEWS +file.edit("NEWS.md") # Check spelling dict <- hunspell::dictionary('en_CA') devtools::spell_check() spelling::update_wordlist() +# Check URLS +urlchecker::url_check() + # Check test coverage #covr::report() # Update README.Rmd -# Compile README.md -# REBUILD! devtools::build_readme() -# Check/update URLS -urlchecker::url_check() - # Precompile Vignettes source("vignettes/precompile.R") - ## Checks - - # Run WITH and WITHOUT internet -#devtools::run_examples(run_donttest = TRUE) -#devtools::test() -# Local tests, as CRAN and not as CRAN -devtools::check(remote = TRUE, manual = TRUE, run_dont_test = TRUE, - env_vars = list("NOT_CRAN" = "")) -devtools::check(remote = TRUE, manual = TRUE, run_dont_test = TRUE) +devtools::run_examples(run_donttest = TRUE) +devtools::test() +# Local tests +devtools::check(cran = FALSE, manual = TRUE, run_dont_test = TRUE) +devtools::check(cran = FALSE, manual = TRUE, + args = c("--no-examples", "--no-tests")) # Quick re-check as needed +devtools::check_win_devel() ## Update codemeta codemetar::write_codemeta() @@ -76,7 +71,8 @@ usethis::use_dev_version() - +# Good practices -------------------- +goodpractice::gp() diff --git a/vignettes/articles/tidyhydat.Rmd b/vignettes/articles/tidyhydat.Rmd index 640fb04..98e5dba 100644 --- a/vignettes/articles/tidyhydat.Rmd +++ b/vignettes/articles/tidyhydat.Rmd @@ -1,7 +1,7 @@ --- title: "weathercan and tidyhydat" author: "Steffi LaZerte" -date: "2023-09-20" +date: "2024-11-12" output: rmarkdown::html_document --- @@ -22,7 +22,7 @@ can compliment weather data from `weathercan` (and vice versa). ### Loading packages -```r +``` r library(weathercan) library(tidyhydat) ``` @@ -31,7 +31,7 @@ library(tidyhydat) ## Error in library(tidyhydat): there is no package called 'tidyhydat' ``` -```r +``` r library(dplyr) library(ggplot2) library(lubridate) @@ -44,7 +44,7 @@ library(glue) (Note, this can take a while!) -```r +``` r download_hydat() ``` @@ -62,50 +62,54 @@ The event occurred in late June/early July, so let's give ourselves a two-month range. -```r +``` r dates <- c("2020-06-01", "2020-08-01") ``` We'll find a local Brandon weather station that has daily data for this range -```r +``` r stations_search("brandon", interval = "day", starts_latest = 2020, ends_earliest = 2020) ``` ``` ## # A tibble: 2 × 16 -## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz interval start end normals -## -## 1 MB BRANDON A 50821 5010481 71140 YBR 49.9 -100. 409. Etc/GMT+6 day 2012 2023 FALSE -## 2 MB BRANDON RCS 49909 5010490 71136 PBO 49.9 -100. 409. Etc/GMT+6 day 2012 2023 FALSE +## prov station_name station_id climate_id WMO_id TC_id lat lon elev tz interval start end normals normals_1981_2010 +## +## 1 MB BRANDON A 50821 5010481 71140 YBR 49.9 -100. 409. Etc/GMT+6 day 2012 2023 FALSE FALSE +## 2 MB BRANDON RCS 49909 5010490 71136 PBO 49.9 -100. 409. Etc/GMT+6 day 2012 2023 FALSE FALSE +## # ℹ 1 more variable: normals_1971_2000 ``` In this case "A" is for "Airport", let's go with that! -```r +``` r rain <- weather_dl(station_ids = 50821, interval = "day", start = dates[1], end = dates[2]) ``` Take a quick look: -```r +``` r ggplot(data = rain, aes(x = date, y = total_rain)) + theme_bw() + geom_bar(stat = "identity") + scale_y_continuous(name = "Total Rain (mm)", expand = c(0,0)) ``` -plot of chunk unnamed-chunk-7 +
+plot of chunk unnamed-chunk-7 +

plot of chunk unnamed-chunk-7

+
Yikes! You can see why my downspout came off! Now let's get some HYDAT data to compare. First we'll find a local station -```r +``` r search_stn_name("brandon") ``` @@ -118,7 +122,7 @@ to only Manitoba and only stations with 2020 data with the `hy_stn_data_range()` function. -```r +``` r search_stn_name("brandon") %>% filter(PROV_TERR_STATE_LOC == "MB") %>% pull(STATION_NUMBER) %>% @@ -134,7 +138,7 @@ Hmm, let's see what kind of data is available by looking at the included `hy_data_types` data frame. -```r +``` r filter(hy_data_types, DATA_TYPE %in% c("H", "Q")) ``` @@ -148,7 +152,7 @@ Great! We have both flow and water level data for a station number "05MH001", Let's grab the flow and water level data for this station. -```r +``` r flow <- hy_daily_flows(station_number = "05MH001", start_date = dates[1], end_date = dates[2]) ``` @@ -157,7 +161,7 @@ flow <- hy_daily_flows(station_number = "05MH001", ## Error in hy_daily_flows(station_number = "05MH001", start_date = dates[1], : could not find function "hy_daily_flows" ``` -```r +``` r level <- hy_daily_levels(station_number = "05MH001", start_date = dates[1], end_date = dates[2]) ``` @@ -169,7 +173,7 @@ level <- hy_daily_levels(station_number = "05MH001", ### Ploting rain and flow -```r +``` r g <- ggplot() + theme_bw() + theme(axis.title.x = element_blank()) + @@ -185,7 +189,7 @@ g <- ggplot() + ## Error in eval(expr, envir, enclos): object 'flow' not found ``` -```r +``` r g ``` @@ -201,7 +205,7 @@ called "lag to peak"). Let's add a bit of information about this lag to peak. -```r +``` r d <- data.frame(dates = c(rain$date[which.max(rain$total_precip)], flow$Date[which.max(flow$Value)]), y = max(flow$Value) + 5) @@ -211,7 +215,7 @@ d <- data.frame(dates = c(rain$date[which.max(rain$total_precip)], ## Error in eval(expr, envir, enclos): object 'flow' not found ``` -```r +``` r g + geom_path(data = d, aes(x = dates, y = y), arrow = arrow(length = unit(0.25, "lines"), ends = "both", type = "closed")) + @@ -233,7 +237,7 @@ local contributions), which takes time to travel. ### Ploting rain and water level -```r +``` r g <- ggplot() + theme_bw() + theme(axis.title.x = element_blank()) + @@ -251,7 +255,7 @@ g <- ggplot() + ## Error in eval(expr, envir, enclos): object 'level' not found ``` -```r +``` r g ``` @@ -262,7 +266,7 @@ g Again there looks to be a lag, let's see if it's the same as before. -```r +``` r d <- data.frame(dates = c(rain$date[which.max(rain$total_precip)], level$Date[which.max(level$Value)]), y = max(level$Value)*1.00025) @@ -272,7 +276,7 @@ d <- data.frame(dates = c(rain$date[which.max(rain$total_precip)], ## Error in eval(expr, envir, enclos): object 'level' not found ``` -```r +``` r g + geom_path(data = d, aes(x = dates, y = y), arrow = arrow(length = unit(0.25, "lines"), ends = "both", type = "closed")) + @@ -292,7 +296,7 @@ g + Looks like the flow and water level match up, perhaps we should take a closer look. -```r +``` r ggplot() + theme_bw() + theme(legend.position = c(0.8, 0.8)) + @@ -308,6 +312,13 @@ ggplot() + "Level" = "grey30")) ``` +``` +## Warning: A numeric `legend.position` argument in `theme()` was deprecated in ggplot2 3.5.0. +## ℹ Please use the `legend.position.inside` argument of `theme()` instead. +## This warning is displayed once every 8 hours. +## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. +``` + ``` ## Error in eval(expr, envir, enclos): object 'flow' not found ``` diff --git a/vignettes/figures/interp-unnamed-chunk-10-1.png b/vignettes/figures/interp-unnamed-chunk-10-1.png index 017b47d..ad8625a 100644 Binary files a/vignettes/figures/interp-unnamed-chunk-10-1.png and b/vignettes/figures/interp-unnamed-chunk-10-1.png differ diff --git a/vignettes/figures/interp-unnamed-chunk-11-1.png b/vignettes/figures/interp-unnamed-chunk-11-1.png index 3408e67..f13702c 100644 Binary files a/vignettes/figures/interp-unnamed-chunk-11-1.png and b/vignettes/figures/interp-unnamed-chunk-11-1.png differ diff --git a/vignettes/figures/interp-unnamed-chunk-13-1.png b/vignettes/figures/interp-unnamed-chunk-13-1.png index 863c9d2..53f710a 100644 Binary files a/vignettes/figures/interp-unnamed-chunk-13-1.png and b/vignettes/figures/interp-unnamed-chunk-13-1.png differ diff --git a/vignettes/figures/normals-unnamed-chunk-7-1.png b/vignettes/figures/normals-unnamed-chunk-7-1.png new file mode 100644 index 0000000..2624590 Binary files /dev/null and b/vignettes/figures/normals-unnamed-chunk-7-1.png differ diff --git a/vignettes/flags.Rmd b/vignettes/flags.Rmd index 906f989..7b48ec1 100644 --- a/vignettes/flags.Rmd +++ b/vignettes/flags.Rmd @@ -1,7 +1,7 @@ --- title: "Flags and codes" author: "Steffi LaZerte" -date: "2023-09-20" +date: "2024-11-12" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Flags and codes} @@ -40,7 +40,8 @@ For example, a sample of unformatted data from Magog station in Quebec looks lik ## 9 MAGOG 2017-11 70.0 ^ 0 ## 10 MAGOG 2017-12 45.7 ^ 10 ## 11 MAGOG 2018-01 34.6 ^ 2 -## 12 MAGOG 2018-02 77.2 ^ 0 +## 12 MAGOG 2018-02 77.2 ^ 0 +## # ℹ 1 more variable: `Snow Grnd Last Day Flag` ``` In this output, you can see two flags: `^` in `Total Precip` and `M` in `Snow Grnd Last Day` @@ -95,6 +96,23 @@ The flags index can be accessed through the built in data frame: `flags` In the `normals_dl`() function, codes are associated with each variable: +``` +## Warning: There were 2 warnings in `dplyr::mutate()`. +## The first warning was: +## ℹ In argument: `frost = purrr::map2(...)`. +## Caused by warning: +## ! 21 parsing failures. +## row col expected actual file +## 4 -- 3 columns 15 columns literal data +## 5 -- 3 columns 15 columns literal data +## 6 -- 3 columns 15 columns literal data +## 7 -- 3 columns 15 columns literal data +## 8 -- 3 columns 15 columns literal data +## ... ... ......... .......... ............ +## See problems(...) for more details. +## ℹ Run `dplyr::last_dplyr_warnings()` to see the 1 remaining warning. +``` + ``` ## # A tibble: 13 × 7 ## period temp_daily_average temp_daily_average_code temp_daily_max temp_daily_max_code @@ -111,7 +129,8 @@ In the `normals_dl`() function, codes are associated with each variable: ## 10 Oct 4.1 A 10.4 A ## 11 Nov -5.6 A -0.5 A ## 12 Dec -14 A -9 A -## 13 Year 2.2 A 8.4 A +## 13 Year 2.2 A 8.4 A +## # ℹ 2 more variables: temp_daily_min , temp_daily_min_code ``` For example, here, the code indicates that these temperature variables meet the WMO '3 and 5 rule' (no more than 3 consecutive and no more than 5 total missing for either temperature or precipitation). diff --git a/vignettes/interpolate_data.Rmd b/vignettes/interpolate_data.Rmd index 587a1a3..ff05ae9 100644 --- a/vignettes/interpolate_data.Rmd +++ b/vignettes/interpolate_data.Rmd @@ -1,7 +1,7 @@ --- title: "Interpolating" author: "Steffi LaZerte" -date: "2023-09-20" +date: "2024-11-12" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Interpolating} @@ -17,7 +17,7 @@ vignette: > You'll need several packages from the **tidyverse** in addition to **`weathercan`** to complete the following analysis. -```r +``` r library(weathercan) library(ggplot2) library(dplyr) @@ -29,71 +29,71 @@ You can merge weather data with other data frames by linearly interpolating betw For example, here we have a dataset of weather data from Kamloops -```r +``` r glimpse(kamloops) ``` ``` ## Rows: 4,368 ## Columns: 37 -## $ station_name "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A", "KAMLO… -## $ station_id 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423,… -## $ station_operator NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ prov "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", … -## $ lat 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, … -## $ lon -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, … -## $ elev 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3,… -## $ climate_id "1163781", "1163781", "1163781", "1163781", "1163781", "1163781", "1163781", "1163781", "1… -## $ WMO_id "71887", "71887", "71887", "71887", "71887", "71887", "71887", "71887", "71887", "71887", … -## $ TC_id "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA",… -## $ date 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, 2016-… -## $ time 2016-01-01 00:00:00, 2016-01-01 01:00:00, 2016-01-01 02:00:00, 2016-01-01 03:00:00, 2016-… -## $ year "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2… -## $ month "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", … -## $ day "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", … -## $ hour "00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", … -## $ weather NA, "Mostly Cloudy", NA, NA, "Cloudy", NA, NA, "Cloudy", NA, "Snow", "Snow", "Snow", "Snow… -## $ hmdx NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ hmdx_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ precip_amt NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ precip_amt_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ pressure 99.95, 99.93, 99.92, 99.90, 99.86, 99.82, 99.80, 99.78, 99.77, 99.78, 99.79, 99.74, 99.69,… -## $ pressure_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ rel_hum 74, 76, 74, 73, 70, 71, 69, 69, 71, 71, 71, 70, 69, 70, 68, 68, 70, 74, 73, 74, 74, 74, 77… -## $ rel_hum_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ temp -9.1, -9.6, -9.9, -9.5, -9.4, -9.8, -10.0, -10.2, -10.1, -9.7, -9.4, -9.0, -8.6, -8.2, -8.… -## $ temp_dew -12.9, -13.1, -13.7, -13.5, -13.9, -14.1, -14.7, -14.9, -14.4, -14.0, -13.7, -13.5, -13.3,… -## $ temp_dew_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ temp_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ visib 64.4, 64.4, 64.4, 64.4, 64.4, 64.4, 64.4, 64.4, 48.3, 48.3, 48.3, 48.3, 48.3, 48.3, 48.3, … -## $ visib_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ wind_chill -17, -17, -18, -17, -17, -17, -18, -17, -17, -16, -15, -14, -14, -13, -13, -13, -13, -14, … -## $ wind_chill_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ wind_dir 13, 11, 11, 11, 11, 10, 9, 7, 7, 10, 11, 10, 10, 13, 11, 10, 10, 9, 12, 10, 13, 12, 10, 12… -## $ wind_dir_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… -## $ wind_spd 19, 20, 20, 18, 18, 16, 23, 15, 14, 15, 12, 11, 12, 9, 10, 12, 11, 12, 10, 11, 11, 6, 6, 4… -## $ wind_spd_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA… +## $ station_name "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A", "KAMLOOPS A… +## $ station_id 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 51423, 5142… +## $ station_operator NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ prov "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "BC", "… +## $ lat 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 50.7, 5… +## $ lon -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -120.45, -… +## $ elev 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.3, 345.… +## $ climate_id "1163781", "1163781", "1163781", "1163781", "1163781", "1163781", "1163781", "1163781", "1163781", "1163781",… +## $ WMO_id "71887", "71887", "71887", "71887", "71887", "71887", "71887", "71887", "71887", "71887", "71887", "71887", "… +## $ TC_id "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA", "YKA… +## $ date 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, 2016-01-01, … +## $ time 2016-01-01 00:00:00, 2016-01-01 01:00:00, 2016-01-01 02:00:00, 2016-01-01 03:00:00, 2016-01-01 04:00:00, 201… +## $ year "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016", "2016… +## $ month "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "… +## $ day "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "01", "… +## $ hour "00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "… +## $ weather NA, "Mostly Cloudy", NA, NA, "Cloudy", NA, NA, "Cloudy", NA, "Snow", "Snow", "Snow", "Snow", "Snow", "Snow", … +## $ hmdx NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ hmdx_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ precip_amt NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ precip_amt_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ pressure 99.95, 99.93, 99.92, 99.90, 99.86, 99.82, 99.80, 99.78, 99.77, 99.78, 99.79, 99.74, 99.69, 99.62, 99.56, 99.5… +## $ pressure_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ rel_hum 74, 76, 74, 73, 70, 71, 69, 69, 71, 71, 71, 70, 69, 70, 68, 68, 70, 74, 73, 74, 74, 74, 77, 72, 72, 73, 74, 7… +## $ rel_hum_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ temp -9.1, -9.6, -9.9, -9.5, -9.4, -9.8, -10.0, -10.2, -10.1, -9.7, -9.4, -9.0, -8.6, -8.2, -8.1, -7.7, -8.1, -8.5… +## $ temp_dew -12.9, -13.1, -13.7, -13.5, -13.9, -14.1, -14.7, -14.9, -14.4, -14.0, -13.7, -13.5, -13.3, -12.8, -13.0, -12.… +## $ temp_dew_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ temp_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ visib 64.4, 64.4, 64.4, 64.4, 64.4, 64.4, 64.4, 64.4, 48.3, 48.3, 48.3, 48.3, 48.3, 48.3, 48.3, 48.3, 24.1, 48.3, 4… +## $ visib_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ wind_chill -17, -17, -18, -17, -17, -17, -18, -17, -17, -16, -15, -14, -14, -13, -13, -13, -13, -14, -13, -14, -14, -12,… +## $ wind_chill_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ wind_dir 13, 11, 11, 11, 11, 10, 9, 7, 7, 10, 11, 10, 10, 13, 11, 10, 10, 9, 12, 10, 13, 12, 10, 12, NA, 32, 26, 26, 2… +## $ wind_dir_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +## $ wind_spd 19, 20, 20, 18, 18, 16, 23, 15, 14, 15, 12, 11, 12, 9, 10, 12, 11, 12, 10, 11, 11, 6, 6, 4, 0, 4, 9, 10, 8, 7… +## $ wind_spd_flag NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… ``` As well as a data set of finch visits to an RFID feeder -```r +``` r glimpse(finches) ``` ``` ## Rows: 16,886 ## Columns: 10 -## $ animal_id 041868FF93, 041868FF93, 041868FF93, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 0… -## $ date 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, … -## $ time 2016-03-01 06:57:42, 2016-03-01 06:58:41, 2016-03-01 07:07:21, 2016-03-01 07:32:34, 2016-03-01 0… -## $ logger_id 2300, 2300, 2300, 2400, 2400, 2400, 2400, 2400, 2300, 2300, 2300, 2300, 2300, 2400, 2300, 2400, 2… -## $ species "Mountain Chickadee", "Mountain Chickadee", "Mountain Chickadee", "House Finch", "House Finch", "… -## $ age "AHY", "AHY", "AHY", "SY", "SY", "SY", "SY", "SY", "AHY", "AHY", "AHY", "AHY", "AHY", "SY", "AHY"… -## $ sex "U", "U", "U", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "M", "F", "M", "M", "M", "M", "M… -## $ site_name "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "… -## $ lon -120.3622, -120.3622, -120.3622, -120.3635, -120.3635, -120.3635, -120.3635, -120.3635, -120.3622… -## $ lat 50.66967, 50.66967, 50.66967, 50.66938, 50.66938, 50.66938, 50.66938, 50.66938, 50.66967, 50.6696… +## $ animal_id 041868FF93, 041868FF93, 041868FF93, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 041868BED6, 041868BE… +## $ date 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03… +## $ time 2016-03-01 06:57:42, 2016-03-01 06:58:41, 2016-03-01 07:07:21, 2016-03-01 07:32:34, 2016-03-01 07:32:35, 2016-03-01… +## $ logger_id 2300, 2300, 2300, 2400, 2400, 2400, 2400, 2400, 2300, 2300, 2300, 2300, 2300, 2400, 2300, 2400, 2400, 2400, 2400, 24… +## $ species "Mountain Chickadee", "Mountain Chickadee", "Mountain Chickadee", "House Finch", "House Finch", "House Finch", "Hous… +## $ age "AHY", "AHY", "AHY", "SY", "SY", "SY", "SY", "SY", "AHY", "AHY", "AHY", "AHY", "AHY", "SY", "AHY", "SY", "SY", "SY",… +## $ sex "U", "U", "U", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "M", "F", "M", "M", "M", "M", "M", "F", "M", "M", "… +## $ site_name "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kam… +## $ lon -120.3622, -120.3622, -120.3622, -120.3635, -120.3635, -120.3635, -120.3635, -120.3635, -120.3622, -120.3622, -120.3… +## $ lat 50.66967, 50.66967, 50.66967, 50.66938, 50.66938, 50.66938, 50.66938, 50.66938, 50.66967, 50.66967, 50.66967, 50.669… ``` Although the times in the weather data do not exactly match those in the finch data, we can merge them together through linear [interpolation](https://en.wikipedia.org/wiki/Linear_interpolation). This function uses the `approx` function from the `stats` package under the hood. @@ -101,12 +101,12 @@ Although the times in the weather data do not exactly match those in the finch d Here we specify that we only want the temperature (`temp`) column: -```r +``` r finches_temperature <- weather_interp(data = finches, weather = kamloops, cols = "temp") ``` ``` -## temp is missing 4 out of 4368 data, interpolation may be less accurate as a result. +## Error: `data` and `weather` timezones must match ``` Ooops! What happened? @@ -116,25 +116,23 @@ Well the weather data on Kamloops returned by `weathercan` has times set in the scored as "UTC" according to R. -```r +``` r kamloops$time[1:5] ``` ``` -## [1] "2016-01-01 00:00:00 UTC" "2016-01-01 01:00:00 UTC" "2016-01-01 02:00:00 UTC" "2016-01-01 03:00:00 UTC" -## [5] "2016-01-01 04:00:00 UTC" +## [1] "2016-01-01 00:00:00 UTC" "2016-01-01 01:00:00 UTC" "2016-01-01 02:00:00 UTC" "2016-01-01 03:00:00 UTC" "2016-01-01 04:00:00 UTC" ``` The `finches` data, on the other hand, is set in a true timezone: -```r +``` r finches$time[1:5] ``` ``` -## [1] "2016-03-01 06:57:42 UTC" "2016-03-01 06:58:41 UTC" "2016-03-01 07:07:21 UTC" "2016-03-01 07:32:34 UTC" -## [5] "2016-03-01 07:32:35 UTC" +## [1] "2016-03-01 06:57:42 -08" "2016-03-01 06:58:41 -08" "2016-03-01 07:07:21 -08" "2016-03-01 07:32:34 -08" "2016-03-01 07:32:35 -08" ``` This means that it also has daylight savings applied, eep! @@ -148,14 +146,14 @@ First we'll transform it to non-daylight savings with the `with_tz()` function from the `lubridate` package. -```r +``` r finches <- mutate(finches, time = lubridate::with_tz(time, "Etc/GMT+8")) ``` Now we'll force to UTC with the `force_tz()` function from the `lubridate` package. -```r +``` r finches <- mutate(finches, time = lubridate::force_tz(time, "UTC")) ``` @@ -164,7 +162,7 @@ Now `finches` and `kamloops` data are in the same nominal and actual timezones! Let's continue -```r +``` r finches_temperature <- weather_interp(data = finches, weather = kamloops, cols = "temp") ``` @@ -172,52 +170,52 @@ finches_temperature <- weather_interp(data = finches, weather = kamloops, cols = ## temp is missing 4 out of 4368 data, interpolation may be less accurate as a result. ``` -```r +``` r summary(finches_temperature) ``` ``` -## animal_id date time logger_id species -## 0620000513:7624 Min. :2016-03-01 Min. :2016-02-29 22:57:42.00 1500:6370 Length:16886 -## 041868D861:2767 1st Qu.:2016-03-05 1st Qu.:2016-03-05 05:54:13.25 2100: 968 Class :character -## 0620000514:1844 Median :2016-03-09 Median :2016-03-09 08:54:47.00 2200:2266 Mode :character -## 06200004F8:1386 Mean :2016-03-08 Mean :2016-03-08 23:45:58.05 2300:3531 -## 041868BED6: 944 3rd Qu.:2016-03-13 3rd Qu.:2016-03-13 00:24:58.75 2400:1477 -## 06200003BB: 708 Max. :2016-03-16 Max. :2016-03-16 08:39:30.00 2700:2274 -## (Other) :1613 -## age sex site_name lon lat temp -## Length:16886 Length:16886 Length:16886 Min. :-120.4 Min. :50.67 Min. :-2.578 -## Class :character Class :character Class :character 1st Qu.:-120.4 1st Qu.:50.67 1st Qu.: 2.410 -## Mode :character Mode :character Mode :character Median :-120.4 Median :50.67 Median : 4.820 -## Mean :-120.4 Mean :50.67 Mean : 4.731 -## 3rd Qu.:-120.4 3rd Qu.:50.67 3rd Qu.: 7.260 -## Max. :-120.4 Max. :50.67 Max. :11.989 +## animal_id date time logger_id species age +## 0620000513:7624 Min. :2016-03-01 Min. :2016-03-01 06:57:42.00 1500:6370 Length:16886 Length:16886 +## 041868D861:2767 1st Qu.:2016-03-05 1st Qu.:2016-03-05 13:54:13.25 2100: 968 Class :character Class :character +## 0620000514:1844 Median :2016-03-09 Median :2016-03-09 16:54:47.00 2200:2266 Mode :character Mode :character +## 06200004F8:1386 Mean :2016-03-08 Mean :2016-03-09 07:45:58.05 2300:3531 +## 041868BED6: 944 3rd Qu.:2016-03-13 3rd Qu.:2016-03-13 08:24:58.75 2400:1477 +## 06200003BB: 708 Max. :2016-03-16 Max. :2016-03-16 16:39:30.00 2700:2274 +## (Other) :1613 +## sex site_name lon lat temp +## Length:16886 Length:16886 Min. :-120.4 Min. :50.67 Min. :-1.763 +## Class :character Class :character 1st Qu.:-120.4 1st Qu.:50.67 1st Qu.: 5.212 +## Mode :character Mode :character Median :-120.4 Median :50.67 Median : 8.991 +## Mean :-120.4 Mean :50.67 Mean : 8.617 +## 3rd Qu.:-120.4 3rd Qu.:50.67 3rd Qu.:11.943 +## Max. :-120.4 Max. :50.67 Max. :16.353 ## ``` -```r +``` r glimpse(finches_temperature) ``` ``` ## Rows: 16,886 ## Columns: 11 -## $ animal_id 041868FF93, 041868FF93, 041868FF93, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 0… -## $ date 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, … -## $ time 2016-02-29 22:57:42, 2016-02-29 22:58:41, 2016-02-29 23:07:21, 2016-02-29 23:32:34, 2016-02-29 2… -## $ logger_id 2300, 2300, 2300, 2400, 2400, 2400, 2400, 2400, 2300, 2300, 2300, 2300, 2300, 2400, 2300, 2400, 2… -## $ species "Mountain Chickadee", "Mountain Chickadee", "Mountain Chickadee", "House Finch", "House Finch", "… -## $ age "AHY", "AHY", "AHY", "SY", "SY", "SY", "SY", "SY", "AHY", "AHY", "AHY", "AHY", "AHY", "SY", "AHY"… -## $ sex "U", "U", "U", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "M", "F", "M", "M", "M", "M", "M… -## $ site_name "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "… -## $ lon -120.3622, -120.3622, -120.3622, -120.3635, -120.3635, -120.3635, -120.3635, -120.3635, -120.3622… -## $ lat 50.66967, 50.66967, 50.66967, 50.66938, 50.66938, 50.66938, 50.66938, 50.66938, 50.66967, 50.6696… -## $ temp 4.630667, 4.617556, 4.514250, 4.220056, 4.219861, 4.219667, 4.219472, 4.219278, 4.179028, 4.17825… +## $ animal_id 041868FF93, 041868FF93, 041868FF93, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 041868BED6, 041868BE… +## $ date 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03… +## $ time 2016-03-01 06:57:42, 2016-03-01 06:58:41, 2016-03-01 07:07:21, 2016-03-01 07:32:34, 2016-03-01 07:32:35, 2016-03-01… +## $ logger_id 2300, 2300, 2300, 2400, 2400, 2400, 2400, 2400, 2300, 2300, 2300, 2300, 2300, 2400, 2300, 2400, 2400, 2400, 2400, 24… +## $ species "Mountain Chickadee", "Mountain Chickadee", "Mountain Chickadee", "House Finch", "House Finch", "House Finch", "Hous… +## $ age "AHY", "AHY", "AHY", "SY", "SY", "SY", "SY", "SY", "AHY", "AHY", "AHY", "AHY", "AHY", "SY", "AHY", "SY", "SY", "SY",… +## $ sex "U", "U", "U", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "M", "F", "M", "M", "M", "M", "M", "F", "M", "M", "… +## $ site_name "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kam… +## $ lon -120.3622, -120.3622, -120.3622, -120.3635, -120.3635, -120.3635, -120.3635, -120.3635, -120.3622, -120.3622, -120.3… +## $ lat 50.66967, 50.66967, 50.66967, 50.66938, 50.66938, 50.66938, 50.66938, 50.66938, 50.66967, 50.66967, 50.66967, 50.669… +## $ temp 2.396167, 2.397806, 2.424500, 2.508556, 2.508611, 2.508667, 2.508722, 2.508778, 2.520278, 2.520500, 2.522667, 2.5228… ``` Let's take a look at the interpolate points specifically -```r +``` r compare1 <- select(finches_temperature, time, temp) compare1 <- mutate(compare1, type = "interpolated") compare2 <- select(kamloops, time, temp) @@ -230,14 +228,17 @@ ggplot(data = compare, aes(x = time, y = temp, colour = type)) + ``` ``` -## Warning: Removed 4000 rows containing missing values (`geom_point()`). +## Warning: Removed 4000 rows containing missing values or values outside the scale range (`geom_point()`). ``` -plot of chunk unnamed-chunk-10 +
+plot of chunk unnamed-chunk-10 +

plot of chunk unnamed-chunk-10

+
What does this mean for our data? -```r +``` r ggplot(data = finches_temperature, aes(x = temp, fill = animal_id)) + theme_bw() + theme(legend.position = "none") + @@ -245,7 +246,10 @@ ggplot(data = finches_temperature, aes(x = temp, fill = animal_id)) + labs(x = "Temperature (C)", y = "Activity Count", fill = "Finch ID") ``` -plot of chunk unnamed-chunk-11 +
+plot of chunk unnamed-chunk-11 +

plot of chunk unnamed-chunk-11

+
## Data gaps @@ -254,7 +258,7 @@ By default, gaps of 2 hours (or 2 days, with a daily scale) will be interpolated In this example, note the larger number of `NA`s in `temp` and how it corresponds to the missing variables in the weather dataset: -```r +``` r finches_temperature <- weather_interp(data = finches, weather = kamloops, cols = "temp", na_gap = 1) ``` @@ -263,53 +267,53 @@ finches_temperature <- weather_interp(data = finches, weather = kamloops, ## temp is missing 4 out of 4368 data, interpolation may be less accurate as a result. ``` -```r +``` r summary(finches_temperature) ``` ``` -## animal_id date time logger_id species -## 0620000513:7624 Min. :2016-03-01 Min. :2016-02-29 22:57:42.00 1500:6370 Length:16886 -## 041868D861:2767 1st Qu.:2016-03-05 1st Qu.:2016-03-05 05:54:13.25 2100: 968 Class :character -## 0620000514:1844 Median :2016-03-09 Median :2016-03-09 08:54:47.00 2200:2266 Mode :character -## 06200004F8:1386 Mean :2016-03-08 Mean :2016-03-08 23:45:58.05 2300:3531 -## 041868BED6: 944 3rd Qu.:2016-03-13 3rd Qu.:2016-03-13 00:24:58.75 2400:1477 -## 06200003BB: 708 Max. :2016-03-16 Max. :2016-03-16 08:39:30.00 2700:2274 -## (Other) :1613 -## age sex site_name lon lat temp -## Length:16886 Length:16886 Length:16886 Min. :-120.4 Min. :50.67 Min. :-2.578 -## Class :character Class :character Class :character 1st Qu.:-120.4 1st Qu.:50.67 1st Qu.: 2.397 -## Mode :character Mode :character Mode :character Median :-120.4 Median :50.67 Median : 4.819 -## Mean :-120.4 Mean :50.67 Mean : 4.729 -## 3rd Qu.:-120.4 3rd Qu.:50.67 3rd Qu.: 7.273 -## Max. :-120.4 Max. :50.67 Max. :11.989 -## NA's :246 +## animal_id date time logger_id species age +## 0620000513:7624 Min. :2016-03-01 Min. :2016-03-01 06:57:42.00 1500:6370 Length:16886 Length:16886 +## 041868D861:2767 1st Qu.:2016-03-05 1st Qu.:2016-03-05 13:54:13.25 2100: 968 Class :character Class :character +## 0620000514:1844 Median :2016-03-09 Median :2016-03-09 16:54:47.00 2200:2266 Mode :character Mode :character +## 06200004F8:1386 Mean :2016-03-08 Mean :2016-03-09 07:45:58.05 2300:3531 +## 041868BED6: 944 3rd Qu.:2016-03-13 3rd Qu.:2016-03-13 08:24:58.75 2400:1477 +## 06200003BB: 708 Max. :2016-03-16 Max. :2016-03-16 16:39:30.00 2700:2274 +## (Other) :1613 +## sex site_name lon lat temp +## Length:16886 Length:16886 Min. :-120.4 Min. :50.67 Min. :-1.763 +## Class :character Class :character 1st Qu.:-120.4 1st Qu.:50.67 1st Qu.: 5.156 +## Mode :character Mode :character Median :-120.4 Median :50.67 Median : 8.998 +## Mean :-120.4 Mean :50.67 Mean : 8.610 +## 3rd Qu.:-120.4 3rd Qu.:50.67 3rd Qu.:11.951 +## Max. :-120.4 Max. :50.67 Max. :16.353 +## NA's :195 ``` -```r +``` r finches_temperature %>% select(date, time, temp) %>% filter(is.na(temp)) ``` ``` -## # A tibble: 246 × 3 +## # A tibble: 195 × 3 ## date time temp ## -## 1 2016-03-11 2016-03-11 00:08:01 NA -## 2 2016-03-11 2016-03-11 00:08:03 NA -## 3 2016-03-11 2016-03-11 00:08:04 NA -## 4 2016-03-11 2016-03-11 00:08:06 NA -## 5 2016-03-11 2016-03-11 00:22:42 NA -## 6 2016-03-11 2016-03-11 00:22:43 NA -## 7 2016-03-11 2016-03-11 00:22:45 NA -## 8 2016-03-11 2016-03-11 00:22:53 NA -## 9 2016-03-11 2016-03-11 00:22:54 NA -## 10 2016-03-11 2016-03-11 00:23:56 NA -## # ℹ 236 more rows -``` - -```r +## 1 2016-03-08 2016-03-08 12:10:10 NA +## 2 2016-03-08 2016-03-08 12:10:11 NA +## 3 2016-03-08 2016-03-08 12:10:13 NA +## 4 2016-03-08 2016-03-08 12:10:14 NA +## 5 2016-03-08 2016-03-08 12:12:26 NA +## 6 2016-03-08 2016-03-08 12:12:28 NA +## 7 2016-03-08 2016-03-08 12:12:29 NA +## 8 2016-03-08 2016-03-08 12:12:30 NA +## 9 2016-03-08 2016-03-08 12:12:32 NA +## 10 2016-03-08 2016-03-08 12:12:33 NA +## # ℹ 185 more rows +``` + +``` r kamloops %>% select(time, temp) %>% filter(is.na(temp)) @@ -330,7 +334,7 @@ kamloops %>% We could also add in more than one column at a time: -```r +``` r finches_weather <- weather_interp(data = finches, weather = kamloops, cols = c("temp", "wind_spd")) ``` @@ -343,59 +347,51 @@ finches_weather <- weather_interp(data = finches, weather = kamloops, ## wind_spd is missing 4 out of 4368 data, interpolation may be less accurate as a result. ``` -```r +``` r summary(finches_weather) ``` ``` -## animal_id date time logger_id species -## 0620000513:7624 Min. :2016-03-01 Min. :2016-02-29 22:57:42.00 1500:6370 Length:16886 -## 041868D861:2767 1st Qu.:2016-03-05 1st Qu.:2016-03-05 05:54:13.25 2100: 968 Class :character -## 0620000514:1844 Median :2016-03-09 Median :2016-03-09 08:54:47.00 2200:2266 Mode :character -## 06200004F8:1386 Mean :2016-03-08 Mean :2016-03-08 23:45:58.05 2300:3531 -## 041868BED6: 944 3rd Qu.:2016-03-13 3rd Qu.:2016-03-13 00:24:58.75 2400:1477 -## 06200003BB: 708 Max. :2016-03-16 Max. :2016-03-16 08:39:30.00 2700:2274 -## (Other) :1613 -## age sex site_name lon lat temp -## Length:16886 Length:16886 Length:16886 Min. :-120.4 Min. :50.67 Min. :-2.578 -## Class :character Class :character Class :character 1st Qu.:-120.4 1st Qu.:50.67 1st Qu.: 2.410 -## Mode :character Mode :character Mode :character Median :-120.4 Median :50.67 Median : 4.820 -## Mean :-120.4 Mean :50.67 Mean : 4.731 -## 3rd Qu.:-120.4 3rd Qu.:50.67 3rd Qu.: 7.260 -## Max. :-120.4 Max. :50.67 Max. :11.989 -## -## wind_spd -## Min. : 0.000 -## 1st Qu.: 6.519 -## Median :14.096 -## Mean :13.062 -## 3rd Qu.:17.913 -## Max. :41.405 +## animal_id date time logger_id species age +## 0620000513:7624 Min. :2016-03-01 Min. :2016-03-01 06:57:42.00 1500:6370 Length:16886 Length:16886 +## 041868D861:2767 1st Qu.:2016-03-05 1st Qu.:2016-03-05 13:54:13.25 2100: 968 Class :character Class :character +## 0620000514:1844 Median :2016-03-09 Median :2016-03-09 16:54:47.00 2200:2266 Mode :character Mode :character +## 06200004F8:1386 Mean :2016-03-08 Mean :2016-03-09 07:45:58.05 2300:3531 +## 041868BED6: 944 3rd Qu.:2016-03-13 3rd Qu.:2016-03-13 08:24:58.75 2400:1477 +## 06200003BB: 708 Max. :2016-03-16 Max. :2016-03-16 16:39:30.00 2700:2274 +## (Other) :1613 +## sex site_name lon lat temp wind_spd +## Length:16886 Length:16886 Min. :-120.4 Min. :50.67 Min. :-1.763 Min. : 0.00 +## Class :character Class :character 1st Qu.:-120.4 1st Qu.:50.67 1st Qu.: 5.212 1st Qu.:10.35 +## Mode :character Mode :character Median :-120.4 Median :50.67 Median : 8.991 Median :17.72 +## Mean :-120.4 Mean :50.67 Mean : 8.617 Mean :17.15 +## 3rd Qu.:-120.4 3rd Qu.:50.67 3rd Qu.:11.943 3rd Qu.:21.95 +## Max. :-120.4 Max. :50.67 Max. :16.353 Max. :40.93 ## ``` -```r +``` r glimpse(finches_weather) ``` ``` ## Rows: 16,886 ## Columns: 12 -## $ animal_id 041868FF93, 041868FF93, 041868FF93, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 0… -## $ date 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, … -## $ time 2016-02-29 22:57:42, 2016-02-29 22:58:41, 2016-02-29 23:07:21, 2016-02-29 23:32:34, 2016-02-29 2… -## $ logger_id 2300, 2300, 2300, 2400, 2400, 2400, 2400, 2400, 2300, 2300, 2300, 2300, 2300, 2400, 2300, 2400, 2… -## $ species "Mountain Chickadee", "Mountain Chickadee", "Mountain Chickadee", "House Finch", "House Finch", "… -## $ age "AHY", "AHY", "AHY", "SY", "SY", "SY", "SY", "SY", "AHY", "AHY", "AHY", "AHY", "AHY", "SY", "AHY"… -## $ sex "U", "U", "U", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "M", "F", "M", "M", "M", "M", "M… -## $ site_name "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "… -## $ lon -120.3622, -120.3622, -120.3622, -120.3635, -120.3635, -120.3635, -120.3635, -120.3635, -120.3622… -## $ lat 50.66967, 50.66967, 50.66967, 50.66938, 50.66938, 50.66938, 50.66938, 50.66938, 50.66967, 50.6696… -## $ temp 4.630667, 4.617556, 4.514250, 4.220056, 4.219861, 4.219667, 4.219472, 4.219278, 4.179028, 4.17825… -## $ wind_spd 18.88500, 18.93417, 19.49000, 21.17111, 21.17222, 21.17333, 21.17444, 21.17556, 21.40556, 21.4100… -``` - -```r +## $ animal_id 041868FF93, 041868FF93, 041868FF93, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 06200003BB, 041868BED6, 041868BE… +## $ date 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03-01, 2016-03… +## $ time 2016-03-01 06:57:42, 2016-03-01 06:58:41, 2016-03-01 07:07:21, 2016-03-01 07:32:34, 2016-03-01 07:32:35, 2016-03-01… +## $ logger_id 2300, 2300, 2300, 2400, 2400, 2400, 2400, 2400, 2300, 2300, 2300, 2300, 2300, 2400, 2300, 2400, 2400, 2400, 2400, 24… +## $ species "Mountain Chickadee", "Mountain Chickadee", "Mountain Chickadee", "House Finch", "House Finch", "House Finch", "Hous… +## $ age "AHY", "AHY", "AHY", "SY", "SY", "SY", "SY", "SY", "AHY", "AHY", "AHY", "AHY", "AHY", "SY", "AHY", "SY", "SY", "SY",… +## $ sex "U", "U", "U", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "M", "F", "M", "M", "M", "M", "M", "F", "M", "M", "… +## $ site_name "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kamloops, BC", "Kam… +## $ lon -120.3622, -120.3622, -120.3622, -120.3635, -120.3635, -120.3635, -120.3635, -120.3635, -120.3622, -120.3622, -120.3… +## $ lat 50.66967, 50.66967, 50.66967, 50.66938, 50.66938, 50.66938, 50.66938, 50.66938, 50.66967, 50.66967, 50.66967, 50.669… +## $ temp 2.396167, 2.397806, 2.424500, 2.508556, 2.508611, 2.508667, 2.508722, 2.508778, 2.520278, 2.520500, 2.522667, 2.5228… +## $ wind_spd 19.00000, 19.00000, 18.51000, 16.82889, 16.82778, 16.82667, 16.82556, 16.82444, 16.59444, 16.59000, 16.54667, 16.542… +``` + +``` r finches_weather <- finches_weather %>% group_by(date) %>% summarize(n = length(time), @@ -421,7 +417,10 @@ ggplot(data = finches_weather, aes(x = date, y = n)) + ## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. ``` -plot of chunk unnamed-chunk-13 +
+plot of chunk unnamed-chunk-13 +

plot of chunk unnamed-chunk-13

+
diff --git a/vignettes/normals.Rmd b/vignettes/normals.Rmd index 30c127c..9ca394e 100644 --- a/vignettes/normals.Rmd +++ b/vignettes/normals.Rmd @@ -1,7 +1,7 @@ --- title: "Climate Normals" author: "Steffi LaZerte" -date: "2023-09-20" +date: "2024-11-12" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Climate Normals} @@ -18,21 +18,17 @@ Climate Normals and Averages describe the average climate conditions specific to First we'll load the `weathercan` package for downloading the data and the `tidyr` package for unnesting the data (see below). -```r +``` r library(weathercan) library(tidyr) library(dplyr) library(naniar) # For exploring missing values ``` -``` -## Error in library(naniar): there is no package called 'naniar' -``` - To download climate normals, we'll first find the stations we're interested in using the `stations_search()` function. We'll use the `normals_years = "current"` argument to filter to only stations with available climate normals for the `1981-2010` year range. -```r +``` r stations_search("Winnipeg", normals_years = "current") ``` @@ -46,7 +42,7 @@ stations_search("Winnipeg", normals_years = "current") Let's look at the climate normals from this station in Winnipeg, MB. Note that unlike the `weather_dl()` function, the `normals_dl()` function requires `climate_id` not `station_id`. By default the normals are downloaded for the years "1981-2010" (currently 1981-2010 and 1971-2000 are the only year ranges available) -```r +``` r n <- normals_dl(climate_ids = "5023222") n ``` @@ -60,12 +56,12 @@ n Because there are two different types of climate normals (weather measurements and first/last frost dates), the data are nested as two different datasets. We can see that the Airport (Richardson Int'l) has 197 average weather measurements/codes as well as first/last frost dates. -We can also see that this station has data quality sufficient to meet the WMO standards for temperature and precipitation (i.e. both these measurements have code >= A). See the [ECCC calculations document](https://climate.weather.gc.ca/doc/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf) for more details. +We can also see that this station has data quality sufficient to meet the WMO standards for temperature and precipitation (i.e. both these measurements have code >= A). See the [ECCC calculations document](https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf) for more details. To extract either data set we can use the `unnest()` function from the `tidyr` package. -```r +``` r normals <- unnest(n, normals) frost <- unnest(n, frost) ``` @@ -73,7 +69,7 @@ frost <- unnest(n, frost) Note that this extracts the measurements for all three stations (in the case of the `normals` data frame), but not all measurements are available for each station -```r +``` r normals ``` @@ -98,25 +94,26 @@ normals To visualize missing data we can use the `gg_miss_var()` function from the `naniar` package. -```r +``` r select(normals, -contains("_code")) %>% # Remove '_code' columns gg_miss_var(facet = station_name) ``` -```r +``` r suppressWarnings({select(normals, -contains("_code")) %>% # Remove '_code' columns gg_miss_var(facet = station_name)}) ``` -``` -## Error in gg_miss_var(., facet = station_name): could not find function "gg_miss_var" -``` +
+plot of chunk unnamed-chunk-7 +

plot of chunk unnamed-chunk-7

+
Let's take a look at the frost data. -```r +``` r if("normals" %in% names(frost)) frost <- select(frost, -normals) # tidyr v1 glimpse(frost) ``` @@ -134,9 +131,9 @@ glimpse(frost) ## $ date_last_spring_frost 143, 143, 143, 143, 143, 143, 143 ## $ length_frost_free 121, 121, 121, 121, 121, 121, 121 ## $ prob "10%", "25%", "33%", "50%", "66%", "75%", … +## $ prob_last_spring_temp_below_0_on_date 158, 152, 148, 144, 140, 137, 129 ## $ prob_first_fall_temp_below_0_on_date 255, 259, 261, 265, 268, 270, 276 ## $ prob_length_frost_free 96, 109, 114, 119, 126, 129, 141 -## $ prob_last_spring_temp_below_0_on_date 158, 152, 148, 144, 140, 137, 129 ``` ### Finding stations with specific measurements @@ -144,7 +141,7 @@ glimpse(frost) The include data frame, `normals_measurements` contains a list of stations with their corresponding measurements. Be aware that this data might be out of date! -```r +``` r normals_measurements ``` @@ -169,7 +166,7 @@ For example, if you wanted all `climate_id`s for stations that have data on soil temperature for 1981-2010 normals: -```r +``` r normals_measurements %>% filter(stringr::str_detect(measurement, "soil"), normals == "1981-2010") %>% @@ -187,7 +184,7 @@ normals_measurements %>% The measurements contained in the climate normals are very specific. To better understand how they are calculated please explore the following resources: -- ECCC Climate Normals Calculations ([1981-2010](https://climate.weather.gc.ca/doc/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf) | [1971-2000](https://climate.weather.gc.ca/doc/Canadian_Climate_Normals_1971_2000_Calculation_Information.pdf)) +- ECCC Climate Normals Calculations ([1991-2020](https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1991_2020_Calculation_Information.pdf) | ([1981-2010](https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf) | [1971-2000](https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1971_2000_Calculation_Information.pdf)) - [`weathercan` Climate Normals Codes](flags.html) - [ECCC Climate Normals Technical Documentation](https://www.canada.ca/en/environment-climate-change/services/climate-change/canadian-centre-climate-services/display-download/technical-documentation-climate-normals.html) - [`weathercan` Climate Normals Glossary](glossary_normals.html) diff --git a/vignettes/normals.Rmd.orig b/vignettes/normals.Rmd.orig index 5b63ec5..06a5f9a 100644 --- a/vignettes/normals.Rmd.orig +++ b/vignettes/normals.Rmd.orig @@ -44,7 +44,7 @@ n Because there are two different types of climate normals (weather measurements and first/last frost dates), the data are nested as two different datasets. We can see that the Airport (Richardson Int'l) has `r ncol(n$normals[[1]])` average weather measurements/codes as well as first/last frost dates. -We can also see that this station has data quality sufficient to meet the WMO standards for temperature and precipitation (i.e. both these measurements have code >= A). See the [ECCC calculations document](https://climate.weather.gc.ca/doc/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf) for more details. +We can also see that this station has data quality sufficient to meet the WMO standards for temperature and precipitation (i.e. both these measurements have code >= A). See the [ECCC calculations document](https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf) for more details. To extract either data set we can use the `unnest()` function from the `tidyr` package. @@ -100,7 +100,7 @@ normals_measurements %>% The measurements contained in the climate normals are very specific. To better understand how they are calculated please explore the following resources: -- ECCC Climate Normals Calculations ([1981-2010](https://climate.weather.gc.ca/doc/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf) | [1971-2000](https://climate.weather.gc.ca/doc/Canadian_Climate_Normals_1971_2000_Calculation_Information.pdf)) +- ECCC Climate Normals Calculations ([1991-2020](https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1991_2020_Calculation_Information.pdf) | ([1981-2010](https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1981_2010_Calculation_Information.pdf) | [1971-2000](https://collaboration.cmc.ec.gc.ca/cmc/climate/Normals/Canadian_Climate_Normals_1971_2000_Calculation_Information.pdf)) - [`weathercan` Climate Normals Codes](flags.html) - [ECCC Climate Normals Technical Documentation](https://www.canada.ca/en/environment-climate-change/services/climate-change/canadian-centre-climate-services/display-download/technical-documentation-climate-normals.html) - [`weathercan` Climate Normals Glossary](glossary_normals.html) diff --git a/vignettes/reproducibility.Rmd b/vignettes/reproducibility.Rmd index ff2b8c2..344fcc2 100644 --- a/vignettes/reproducibility.Rmd +++ b/vignettes/reproducibility.Rmd @@ -1,7 +1,7 @@ --- title: "Reproducibility" author: "Steffi LaZerte" -date: "2023-09-20" +date: "2024-11-12" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Reproducibility} @@ -26,7 +26,7 @@ compiling reports) with the following information: For example: -```r +``` r # Work library(weathercan) s <- stations_search("Winnipeg", normals_years = "current") @@ -45,15 +45,14 @@ devtools::session_info() # Install devtools if you don't have it ## [1] "2023-01-24 23:30:00 UTC" ## ## $weathercan_modified -## [1] "2023-09-20" +## [1] "2024-11-08" ``` ``` ## To cite 'weathercan' in publications, please use: ## -## LaZerte, Stefanie E and Sam Albers (2018). weathercan: Download and format weather data from -## Environment and Climate Change Canada. The Journal of Open Source Software 3(22):571. -## doi:10.21105/joss.00571. +## LaZerte, Stefanie E and Sam Albers (2018). weathercan: Download and format weather data from Environment and Climate +## Change Canada. The Journal of Open Source Software 3(22):571. doi:10.21105/joss.00571. ## ## A BibTeX entry for LaTeX users is ## @@ -70,159 +69,103 @@ devtools::session_info() # Install devtools if you don't have it ``` ``` -## ─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────── +## ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ## setting value -## version R version 4.3.1 (2023-06-16) -## os Ubuntu 22.04.3 LTS +## version R version 4.4.0 (2024-04-24) +## os Ubuntu 22.04.4 LTS ## system x86_64, linux-gnu ## ui RStudio ## language en_CA:en ## collate en_CA.UTF-8 ## ctype en_CA.UTF-8 ## tz America/Winnipeg -## date 2023-09-20 -## rstudio 2023.06.0+421 Mountain Hydrangea (desktop) -## pandoc 3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown) +## date 2024-11-12 +## rstudio 2024.09.0+375 Cranberry Hibiscus (desktop) +## pandoc 3.2 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/x86_64/ (via rmarkdown) ## -## ─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────── -## ! package * version date (UTC) lib source -## assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.3.0) -## base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.3.0) -## bit 4.0.5 2022-11-15 [1] CRAN (R 4.3.0) -## bit64 4.0.5 2020-08-30 [1] CRAN (R 4.3.0) -## brio 1.1.3 2021-11-30 [1] CRAN (R 4.3.0) -## bslib 0.5.0 2023-06-09 [1] CRAN (R 4.3.0) -## cachem 1.0.8 2023-05-01 [1] CRAN (R 4.3.0) -## callr 3.7.3 2022-11-02 [1] CRAN (R 4.3.0) -## class 7.3-22 2023-05-03 [4] CRAN (R 4.3.1) -## classInt 0.4-9 2023-02-28 [1] CRAN (R 4.3.0) -## cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.0) -## clisymbols 1.2.0 2017-05-21 [1] CRAN (R 4.3.0) -## codemetar 0.3.5 2022-09-02 [1] CRAN (R 4.3.1) -## colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.0) -## covr 3.6.2 2023-03-25 [1] CRAN (R 4.3.0) -## crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.0) -## crul 1.4.0 2023-09-20 [1] https://ropensci.r-universe.dev (R 4.3.1) -## curl 5.0.0 2023-01-12 [1] CRAN (R 4.3.0) -## cyclocomp 1.1.0 2016-09-10 [1] CRAN (R 4.3.0) -## DBI 1.1.3 2022-06-18 [1] CRAN (R 4.3.0) -## desc 1.4.2 2022-09-08 [1] CRAN (R 4.3.0) -## devtools 2.4.5 2022-10-11 [1] CRAN (R 4.3.0) -## diffviewer 0.1.1 2021-09-30 [1] CRAN (R 4.3.1) -## digest 0.6.31 2022-12-11 [1] CRAN (R 4.3.0) -## dplyr * 1.1.2 2023-04-20 [1] CRAN (R 4.3.0) -## e1071 1.7-13 2023-02-01 [1] CRAN (R 4.3.0) -## ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.3.0) -## evaluate 0.20 2023-01-17 [1] CRAN (R 4.3.0) -## fansi 1.0.4 2023-01-22 [1] CRAN (R 4.3.0) -## farver 2.1.1 2022-07-06 [1] CRAN (R 4.3.0) -## fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0) -## fauxpas 0.5.2 2023-05-03 [1] CRAN (R 4.3.1) -## fs 1.6.2 2023-04-25 [1] CRAN (R 4.3.0) -## generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.0) -## ggplot2 * 3.4.2 2023-04-03 [1] CRAN (R 4.3.0) -## glue * 1.6.2 2022-02-24 [1] CRAN (R 4.3.0) -## goodpractice 1.0.4 2022-08-30 [1] CRAN (R 4.3.0) -## gtable 0.3.3 2023-03-21 [1] CRAN (R 4.3.0) -## highr 0.10 2022-12-22 [1] CRAN (R 4.3.0) -## hms 1.1.3 2023-03-21 [1] CRAN (R 4.3.0) -## htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.3.0) -## htmlwidgets 1.6.2 2023-03-17 [1] CRAN (R 4.3.0) -## httpcode 0.3.0 2020-04-10 [1] CRAN (R 4.3.0) -## httpuv 1.6.9 2023-02-14 [1] CRAN (R 4.3.0) -## httr 1.4.5 2023-02-24 [1] CRAN (R 4.3.0) -## hunspell 3.0.2 2022-09-04 [1] CRAN (R 4.3.0) -## jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.3.0) -## jsonlite 1.8.4 2022-12-06 [1] CRAN (R 4.3.0) -## KernSmooth 2.23-22 2023-07-10 [4] CRAN (R 4.3.1) -## knitr * 1.42 2023-01-25 [1] CRAN (R 4.3.0) -## labeling 0.4.2 2020-10-20 [1] CRAN (R 4.3.0) -## later 1.3.0 2021-08-18 [1] CRAN (R 4.3.0) -## lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.3.0) -## lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.0) -## lintr 3.0.2 2022-10-19 [1] CRAN (R 4.3.0) -## lubridate * 1.9.2.9000 2023-09-20 [1] https://ropensci.r-universe.dev (R 4.3.1) -## lutz 0.3.1 2019-07-19 [1] CRAN (R 4.3.0) -## magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0) -## memoise 2.0.1 2021-11-26 [1] CRAN (R 4.3.0) -## mime 0.12 2021-09-28 [1] CRAN (R 4.3.0) -## miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.3.0) -## munsell 0.5.0 2018-06-12 [1] CRAN (R 4.3.0) -## pak 0.5.1 2023-04-27 [1] CRAN (R 4.3.0) -## parsedate 1.3.1 2022-10-27 [1] CRAN (R 4.3.0) -## pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0) -## pingr 2.0.2 2022-10-26 [1] CRAN (R 4.3.1) -## pkgbuild 1.4.0 2022-11-27 [1] CRAN (R 4.3.0) -## pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0) -## pkgdown 2.0.7 2022-12-14 [1] CRAN (R 4.3.0) -## pkgload 1.3.2 2022-11-16 [1] CRAN (R 4.3.0) -## praise 1.0.0 2015-08-11 [1] CRAN (R 4.3.0) -## prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.3.0) -## processx 3.8.1 2023-04-18 [1] CRAN (R 4.3.0) -## profvis 0.3.7 2020-11-02 [1] CRAN (R 4.3.0) -## promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.3.0) -## proxy 0.4-27 2022-06-09 [1] CRAN (R 4.3.0) -## ps 1.7.5 2023-04-18 [1] CRAN (R 4.3.0) -## purrr 1.0.1 2023-01-10 [1] CRAN (R 4.3.0) -## R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0) -## rappdirs 0.3.3 2021-01-31 [1] CRAN (R 4.3.0) -## rcmdcheck 1.4.0 2021-09-27 [1] CRAN (R 4.3.0) -## Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.3.0) -## readr * 2.1.4 2023-02-10 [1] CRAN (R 4.3.0) -## rematch 1.0.1 2016-04-21 [1] CRAN (R 4.3.0) -## remotes 2.4.2 2021-11-30 [1] CRAN (R 4.3.0) -## rex 1.2.1 2021-11-26 [1] CRAN (R 4.3.0) -## rhub 1.1.2 2022-08-31 [1] CRAN (R 4.3.0) -## rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.0) -## rmarkdown 2.21 2023-03-26 [1] CRAN (R 4.3.0) -## rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.3.0) -## rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.3.0) -## rvest * 1.0.3 2022-08-19 [1] CRAN (R 4.3.0) -## s2 1.1.3 2023-04-27 [1] CRAN (R 4.3.0) -## sass 0.4.5 2023-01-24 [1] CRAN (R 4.3.0) -## scales 1.2.1 2022-08-20 [1] CRAN (R 4.3.0) -## selectr 0.4-2 2019-11-20 [1] CRAN (R 4.3.0) -## sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0) -## sf 1.0-12 2023-03-19 [1] CRAN (R 4.3.0) -## shiny * 1.7.4 2022-12-15 [1] CRAN (R 4.3.0) -## spelling 2.2.1 2023-03-22 [1] CRAN (R 4.3.0) -## stringi 1.7.12 2023-01-11 [1] CRAN (R 4.3.0) -## stringr * 1.5.0 2022-12-02 [1] CRAN (R 4.3.0) -## testthat * 3.1.7 2023-03-12 [1] CRAN (R 4.3.0) -## tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0) -## tidyr * 1.3.0 2023-01-24 [1] CRAN (R 4.3.0) -## tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.0) -## timechange 0.2.0 2023-01-11 [1] CRAN (R 4.3.0) -## triebeard 0.4.1 2023-03-04 [1] CRAN (R 4.3.0) -## tzdb 0.3.0 2022-03-28 [1] CRAN (R 4.3.0) -## units 0.8-2 2023-04-27 [1] CRAN (R 4.3.0) -## urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.3.0) -## urltools 1.7.3 2019-04-14 [1] CRAN (R 4.3.0) -## usethis 2.2.0 2023-06-06 [1] CRAN (R 4.3.0) -## utf8 1.2.3 2023-01-31 [1] CRAN (R 4.3.0) -## uuid 1.1-0 2022-04-19 [1] CRAN (R 4.3.0) -## vcr * 1.2.2.91 2023-09-20 [1] https://ropensci.r-universe.dev (R 4.3.1) -## vctrs 0.6.2 2023-04-19 [1] CRAN (R 4.3.0) -## vroom 1.6.3 2023-04-28 [1] CRAN (R 4.3.0) -## P weathercan * 0.7.0.9000 2023-09-20 [?] load_all() -## webmockr 0.9.0 2023-02-28 [1] CRAN (R 4.3.1) -## whisker 0.4.1 2022-12-05 [1] CRAN (R 4.3.0) -## whoami 1.3.0 2019-03-19 [1] CRAN (R 4.3.0) -## withr 2.5.0 2022-03-03 [1] CRAN (R 4.3.0) -## wk 0.7.3.9000 2023-07-26 [1] Github (paleolimbot/wk@2e38352) -## xfun 0.39 2023-04-20 [1] CRAN (R 4.3.0) -## xml2 1.3.4 2023-04-27 [1] CRAN (R 4.3.0) -## xmlparsedata 1.0.5 2021-03-06 [1] CRAN (R 4.3.0) -## xopen 1.0.0 2018-09-17 [1] CRAN (R 4.3.0) -## xtable 1.8-4 2019-04-21 [1] CRAN (R 4.3.0) -## yaml 2.3.7 2023-01-23 [1] CRAN (R 4.3.0) +## ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +## package * version date (UTC) lib source +## archive 1.1.8 2024-04-28 [1] CRAN (R 4.4.0) +## bit 4.5.0 2024-09-20 [1] CRAN (R 4.4.0) +## bit64 4.5.2 2024-09-22 [1] CRAN (R 4.4.0) +## cachem 1.1.0 2024-05-16 [1] CRAN (R 4.4.0) +## cli 3.6.3 2024-06-21 [1] CRAN (R 4.4.0) +## colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.4.0) +## commonmark 1.9.1 2024-01-30 [1] CRAN (R 4.4.0) +## crayon 1.5.3 2024-06-20 [1] CRAN (R 4.4.0) +## curl 5.2.3 2024-09-20 [1] CRAN (R 4.4.0) +## devtools 2.4.5 2022-10-11 [1] CRAN (R 4.4.0) +## digest 0.6.35 2024-03-11 [1] CRAN (R 4.4.0) +## dplyr * 1.1.4 2023-11-17 [1] CRAN (R 4.4.0) +## ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.4.0) +## evaluate 0.23 2023-11-01 [1] CRAN (R 4.4.0) +## fansi 1.0.6 2023-12-08 [1] CRAN (R 4.4.0) +## farver 2.1.2 2024-05-13 [1] CRAN (R 4.4.0) +## fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.4.0) +## fs 1.6.4 2024-04-25 [1] CRAN (R 4.4.0) +## generics 0.1.3 2022-07-05 [1] CRAN (R 4.4.0) +## ggplot2 * 3.5.1 2024-04-23 [1] CRAN (R 4.4.0) +## glue * 1.8.0 2024-09-30 [1] CRAN (R 4.4.0) +## gtable 0.3.5 2024-04-22 [1] CRAN (R 4.4.0) +## highr 0.11 2024-05-26 [1] CRAN (R 4.4.0) +## hms 1.1.3 2023-03-21 [1] CRAN (R 4.4.0) +## htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0) +## htmlwidgets 1.6.4 2023-12-06 [1] CRAN (R 4.4.0) +## httpuv 1.6.15 2024-03-26 [1] CRAN (R 4.4.0) +## httr 1.4.7 2023-08-15 [1] CRAN (R 4.4.0) +## hunspell 3.0.3 2023-10-06 [1] CRAN (R 4.4.0) +## knitr * 1.47 2024-05-29 [1] CRAN (R 4.4.0) +## labeling 0.4.3 2023-08-29 [1] CRAN (R 4.4.0) +## later 1.3.2 2023-12-06 [1] CRAN (R 4.4.0) +## lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.0) +## lubridate * 1.9.3 2023-09-27 [1] CRAN (R 4.4.0) +## magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.4.0) +## memoise 2.0.1 2021-11-26 [1] CRAN (R 4.4.0) +## mime 0.12 2021-09-28 [1] CRAN (R 4.4.0) +## miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.4.0) +## munsell 0.5.1 2024-04-01 [1] CRAN (R 4.4.0) +## pillar 1.9.0 2023-03-22 [1] CRAN (R 4.4.0) +## pkgbuild 1.4.4 2024-03-17 [1] CRAN (R 4.4.0) +## pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.4.0) +## pkgload 1.3.4 2024-01-16 [1] CRAN (R 4.4.0) +## profvis 0.3.8 2023-05-02 [1] CRAN (R 4.4.0) +## promises 1.3.0 2024-04-05 [1] CRAN (R 4.4.0) +## purrr 1.0.2 2023-08-10 [1] CRAN (R 4.4.0) +## R6 2.5.1 2021-08-19 [1] CRAN (R 4.4.0) +## rappdirs 0.3.3 2021-01-31 [1] CRAN (R 4.4.0) +## Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.4.0) +## readr * 2.1.5 2024-01-10 [1] CRAN (R 4.4.0) +## remotes 2.5.0 2024-03-17 [1] CRAN (R 4.4.0) +## rlang 1.1.4 2024-06-04 [1] CRAN (R 4.4.0) +## rmarkdown 2.27 2024-05-17 [1] CRAN (R 4.4.0) +## rstudioapi 0.17.0 2024-10-16 [1] CRAN (R 4.4.0) +## scales 1.3.0 2023-11-28 [1] CRAN (R 4.4.0) +## sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.4.0) +## shiny 1.8.1.1 2024-04-02 [1] CRAN (R 4.4.0) +## spelling 2.3.0 2024-03-05 [1] CRAN (R 4.4.0) +## stringi 1.8.4 2024-05-06 [1] CRAN (R 4.4.0) +## stringr * 1.5.1 2023-11-14 [1] CRAN (R 4.4.0) +## tibble 3.2.1 2023-03-20 [1] CRAN (R 4.4.0) +## tidyr * 1.3.1 2024-01-24 [1] CRAN (R 4.4.0) +## tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.4.0) +## timechange 0.3.0 2024-01-18 [1] CRAN (R 4.4.0) +## tzdb 0.4.0 2023-05-12 [1] CRAN (R 4.4.0) +## urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.4.0) +## usethis 2.2.3 2024-02-19 [1] CRAN (R 4.4.0) +## utf8 1.2.4 2023-10-22 [1] CRAN (R 4.4.0) +## vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.4.0) +## vroom 1.6.5 2023-12-05 [1] CRAN (R 4.4.0) +## weathercan * 0.7.1 2024-07-09 [1] Github (ropensci/weathercan@f90bb10) +## withr 3.0.1 2024-07-31 [1] CRAN (R 4.4.0) +## xfun 0.44 2024-05-15 [1] CRAN (R 4.4.0) +## xml2 1.3.6 2023-12-04 [1] CRAN (R 4.4.0) +## xtable 1.8-4 2019-04-21 [1] CRAN (R 4.4.0) +## yaml 2.3.8 2023-12-11 [1] CRAN (R 4.4.0) ## -## [1] /home/steffi/R/x86_64-pc-linux-gnu-library/4.3 +## [1] /home/steffi/R/x86_64-pc-linux-gnu-library/4.4 ## [2] /usr/local/lib/R/site-library ## [3] /usr/lib/R/site-library ## [4] /usr/lib/R/library ## -## P ── Loaded and on-disk path mismatch. -## -## ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +## ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ``` diff --git a/vignettes/weathercan.Rmd b/vignettes/weathercan.Rmd index 7710dfb..ded2a82 100644 --- a/vignettes/weathercan.Rmd +++ b/vignettes/weathercan.Rmd @@ -1,7 +1,7 @@ --- title: "Getting Started" author: "Steffi LaZerte" -date: "2023-09-20" +date: "2024-11-12" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting Started} @@ -13,7 +13,7 @@ vignette: > -```r +``` r library(dplyr) library(ggplot2) library(weathercan) @@ -25,7 +25,7 @@ library(weathercan) `weathercan` includes the function `stations()` which returns a list of stations and their details (including `station_id`). -```r +``` r head(stations()) ``` @@ -41,7 +41,7 @@ head(stations()) ## 6 AB EDMONTON CORONATION 1796 301BK03 NA 53.6 -114. 671. Etc/GMT+7 month 1978 1979 FALSE FALSE FALSE ``` -```r +``` r glimpse(stations()) ``` @@ -69,7 +69,7 @@ glimpse(stations()) You can look through this data frame directly, or you can use the `stations_search` function: -```r +``` r stations_search("Kamloops") ``` @@ -93,7 +93,7 @@ stations_search("Kamloops") You can narrow down your search by specifying time intervals (options are "hour", "day", or "month"): -```r +``` r stations_search("Kamloops", interval = "hour") ``` @@ -109,7 +109,7 @@ stations_search("Kamloops", interval = "hour") You can specify more than one interval: -```r +``` r stations_search("Kamloops", interval = c("hour", "month")) ``` @@ -134,7 +134,7 @@ stations_search("Kamloops", interval = c("hour", "month")) You can also search by proximity. These results include a new column `distance` specifying the distance in km from the coordinates: -```r +``` r stations_search(coords = c(50.667492, -120.329049), dist = 20, interval = "hour") ``` @@ -151,7 +151,7 @@ We can also perform more complex searches using `filter()` function from the `dp direction on the data returned by stations(): -```r +``` r BCstations <- stations() %>% filter(prov %in% c("BC")) %>% filter(interval == "hour") %>% @@ -171,7 +171,7 @@ BCstations ## 3 BC WARFIELD RCS 31067 1148705 71401 XWF 49.1 -118. 567. Etc/G… hour 2001 2023 FALSE FALSE FALSE ``` -```r +``` r ## weather_dl() accepts numbers so we can create a vector to input into weather: stn_vector <- BCstations$station_id stn_vector @@ -184,13 +184,13 @@ stn_vector You can update this list of stations with -```r +``` r stations_dl() ``` And check when it was last updated with -```r +``` r stations_meta() ``` @@ -199,7 +199,7 @@ stations_meta() ## [1] "2023-01-24 23:30:00 UTC" ## ## $weathercan_modified -## [1] "2023-09-20" +## [1] "2024-11-08" ``` @@ -208,8 +208,17 @@ stations_meta() Once you have your `station_id`(s) you can download weather data: -```r +``` r kam <- weather_dl(station_ids = 51423, start = "2016-01-01", end = "2016-02-15") +``` + +``` +## As of weathercan v0.3.0 time display is either local time or UTC +## See Details under ?weather_dl for more information. +## This message is shown once per session +``` + +``` r kam ``` @@ -228,12 +237,15 @@ kam ## 9 KAMLOOPS A 51423 NA BC 50.7 -120. 345. 1163781 71887 YKA 2016-01-01 2016-01-01 08:00:00 2016 01 01 08:00 NA ## 10 KAMLOOPS A 51423 NA BC 50.7 -120. 345. 1163781 71887 YKA 2016-01-01 2016-01-01 09:00:00 2016 01 01 09:00 Snow NA ## # ℹ 1,094 more rows +## # ℹ 19 more variables: hmdx_flag , precip_amt , precip_amt_flag , pressure , pressure_flag , rel_hum , rel_hum_flag , +## # temp , temp_dew , temp_dew_flag , temp_flag , visib , visib_flag , wind_chill , wind_chill_flag , wind_dir , +## # wind_dir_flag , wind_spd , wind_spd_flag ``` You can also download data from multiple stations at once: -```r +``` r kam.pg <- weather_dl(station_ids = c(48248, 51423), start = "2016-01-01", end = "2016-02-15") kam.pg @@ -254,25 +266,31 @@ kam.pg ## 9 PRINCE GEOR… 48248 NA BC 53.9 -123. 680 1096453 71302 VXS 2016-01-01 2016-01-01 08:00:00 2016 01 01 08:00 NA ## 10 PRINCE GEOR… 48248 NA BC 53.9 -123. 680 1096453 71302 VXS 2016-01-01 2016-01-01 09:00:00 2016 01 01 09:00 NA ## # ℹ 2,198 more rows +## # ℹ 19 more variables: hmdx_flag , precip_amt , precip_amt_flag , pressure , pressure_flag , rel_hum , rel_hum_flag , +## # temp , temp_dew , temp_dew_flag , temp_flag , visib , visib_flag , wind_chill , wind_chill_flag , wind_dir , +## # wind_dir_flag , wind_spd , wind_spd_flag ``` And plot it: -```r +``` r ggplot(data = kam.pg, aes(x = time, y = temp, group = station_name, colour = station_name)) + theme(legend.position = "top") + geom_line() + theme_minimal() ``` -plot of chunk unnamed-chunk-12 +
+plot of chunk unnamed-chunk-12 +

plot of chunk unnamed-chunk-12

+
Or you can use the vector created above: -```r +``` r stn_vec_df <- weather_dl(station_ids = stn_vector, start = "2016-01-01", end = "2016-02-15") stn_vec_df @@ -293,6 +311,9 @@ stn_vec_df ## 9 CRESTON CAM… 6838 NA BC 49.1 -116. 641. 114B1F0 71770 WJR 2016-01-01 2016-01-01 08:00:00 2016 01 01 08:00 NA ## 10 CRESTON CAM… 6838 NA BC 49.1 -116. 641. 114B1F0 71770 WJR 2016-01-01 2016-01-01 09:00:00 2016 01 01 09:00 NA ## # ℹ 3,302 more rows +## # ℹ 19 more variables: hmdx_flag , precip_amt , precip_amt_flag , pressure , pressure_flag , rel_hum , rel_hum_flag , +## # temp , temp_dew , temp_dew_flag , temp_flag , visib , visib_flag , wind_chill , wind_chill_flag , wind_dir , +## # wind_dir_flag , wind_spd , wind_spd_flag ``` For more information on the data flags, see the [Flags vignette](flags.html), for more information on units and terms, see the [Terms and Units vignette](glossary.html). @@ -302,7 +323,7 @@ For more information on the data flags, see the [Flags vignette](flags.html), fo To access climate normals, you first need to know the `climate_id` associated with the station you're interested in. -```r +``` r stations_search("Winnipeg", normals_years = "current") ``` @@ -317,7 +338,7 @@ The current year range is 1981-2010, but you can also search for stations in the previous year range: -```r +``` r stations_search("Winnipeg", normals_years = "1971-2000") ``` @@ -333,14 +354,31 @@ Note that the Winnipeg station has normals for both year ranges. Then you can download the climate normals with the `normals_dl()` function. -```r +``` r n <- normals_dl("5023222") ``` +``` +## Warning: There were 2 warnings in `dplyr::mutate()`. +## The first warning was: +## ℹ In argument: `frost = purrr::map2(...)`. +## Caused by warning: +## ! 21 parsing failures. +## row col expected actual file +## 4 -- 3 columns 15 columns literal data +## 5 -- 3 columns 15 columns literal data +## 6 -- 3 columns 15 columns literal data +## 7 -- 3 columns 15 columns literal data +## 8 -- 3 columns 15 columns literal data +## ... ... ......... .......... ............ +## See problems(...) for more details. +## ℹ Run `dplyr::last_dplyr_warnings()` to see the 1 remaining warning. +``` + There are two parts to the normals data, average weather measurements and average frost dates. -```r +``` r library(tidyr) unnest(n, normals) ``` @@ -362,30 +400,43 @@ unnest(n, normals) ## 11 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE Nov -4.9 A 3.6 A -0.5 ## 12 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE Dec -13.2 A 4.4 A -8.5 ## 13 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE Year 3 A 1.2 A 8.7 +## # ℹ 192 more variables: temp_daily_max_code , temp_daily_min , temp_daily_min_code , temp_extreme_max , temp_extreme_max_code , +## # temp_extreme_max_date , temp_extreme_max_date_code , temp_extreme_min , temp_extreme_min_code , temp_extreme_min_date , +## # temp_extreme_min_date_code , rain , rain_code , snow , snow_code , precip , precip_code , snow_mean_depth , +## # snow_mean_depth_code , snow_median_depth , snow_median_depth_code , snow_depth_month_end , snow_depth_month_end_code , +## # rain_extreme_daily , rain_extreme_daily_code , rain_extreme_daily_date , rain_extreme_daily_date_code , snow_extreme_daily , +## # snow_extreme_daily_code , snow_extreme_daily_date , snow_extreme_daily_date_code , precip_extreme_daily , +## # precip_extreme_daily_code , precip_extreme_daily_date , precip_extreme_daily_date_code , snow_extreme_depth , … ``` -```r +``` r unnest(n, frost) ``` ``` -## # A tibble: 7 × 14 -## prov station_name climate_id normals_years meets_wmo normals frost_code date_first_fall_frost date_last_spring_frost length_frost_free prob -## -## 1 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 10% -## 2 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 25% -## 3 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 33% -## 4 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 50% -## 5 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 66% -## 6 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 75% -## 7 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 90% +## # A tibble: 6 × 32 +## prov station_name climate_id normals_years meets_wmo normals frost_code date_first_fall_frost date_last_spring_frost length_frost_free +## +## 1 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 +## 2 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 +## 3 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE A 265 143 121 +## 4 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE NA NA NA +## 5 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE NA NA NA +## 6 MB WINNIPEG RICHARDSON INT'L A 5023222 1981-2010 TRUE NA NA NA +## # ℹ 22 more variables: `Probability of first temperature in fall <= 0C, on or before indicated date (10%)` , +## # `Probability of first temperature in fall <= 0C, on or before indicated date (25%)` , +## # `Probability of first temperature in fall <= 0C, on or before indicated date (33%)` , +## # `Probability of first temperature in fall <= 0C, on or before indicated date (50%)` , +## # `Probability of first temperature in fall <= 0C, on or before indicated date (66%)` , +## # `Probability of first temperature in fall <= 0C, on or before indicated date (75%)` , +## # `Probability of first temperature in fall <= 0C, on or before indicated date (90%)` , … ``` Alternatively, download the 1971-2000 normals: -```r +``` r n <- normals_dl("5023222", normals_years = "1971-2000") unnest(n, normals) ``` @@ -407,14 +458,22 @@ unnest(n, normals) ## 11 MB WINNIPEG RICHARDSON INT'L A 5023222 1971-2000 TRUE Nov -5.3 A 3.3 A -0.9 ## 12 MB WINNIPEG RICHARDSON INT'L A 5023222 1971-2000 TRUE Dec -14.4 A 4.2 A -9.7 ## 13 MB WINNIPEG RICHARDSON INT'L A 5023222 1971-2000 TRUE Year 2.6 A 1.3 A 8.3 +## # ℹ 218 more variables: temp_daily_max_code , temp_daily_min , temp_daily_min_code , temp_extreme_max , temp_extreme_max_code , +## # temp_extreme_max_date , temp_extreme_max_date_code , temp_extreme_min , temp_extreme_min_code , temp_extreme_min_date , +## # temp_extreme_min_date_code , rain , rain_code , snow , snow_code , precip , precip_code , snow_mean_depth , +## # snow_mean_depth_code , snow_median_depth , snow_median_depth_code , snow_depth_month_end , snow_depth_month_end_code , +## # rain_extreme_daily , rain_extreme_daily_code , rain_extreme_daily_date , rain_extreme_daily_date_code , snow_extreme_daily , +## # snow_extreme_daily_code , snow_extreme_daily_date , snow_extreme_daily_date_code , precip_extreme_daily , +## # precip_extreme_daily_code , precip_extreme_daily_date , precip_extreme_daily_date_code , snow_extreme_depth , … ``` -```r +``` r unnest(n, frost) ``` ``` ## # A tibble: 0 × 6 +## # ℹ 6 variables: prov , station_name , climate_id , normals_years , meets_wmo , normals ```