From f855781f796898a34e143673e6919d7a0ec5ac7f Mon Sep 17 00:00:00 2001 From: Glenda Yenni Date: Tue, 22 Aug 2023 21:33:14 -0600 Subject: [PATCH] Use new regional weather --- DESCRIPTION | 2 +- NEWS.md | 5 +++++ R/Weather.R | 24 +----------------------- R/portalr-package.R | 15 +++++++-------- README.Rmd | 2 +- man/load_datafile.Rd | 4 ++-- man/portalr.Rd | 33 ++++++++++++++++++++++++++++++++- 7 files changed, 49 insertions(+), 36 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cbdac4f8..81e57dbd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: portalr Title: Create Useful Summaries of the Portal Data -Version: 0.4.0 +Version: 0.4.1 Authors@R: c(person(given = c("Glenda", "M."), family = "Yenni", diff --git a/NEWS.md b/NEWS.md index 570141f7..63514751 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,11 @@ Version numbers follow [Semantic Versioning](https://semver.org/). +# [portalr 0.4.1](https://github.com/weecology/portalr/releases/tag/v0.4.1) +*2023-08-223* + +### Regional weather filling includes more stations + # [portalr 0.4.0](https://github.com/weecology/portalr/releases/tag/v0.4.0) *2023-04-21* diff --git a/R/Weather.R b/R/Weather.R index 0e8ce7d2..d407c060 100644 --- a/R/Weather.R +++ b/R/Weather.R @@ -177,17 +177,7 @@ fill_missing_weather <- function(weather, path = get_default_data_path()) dplyr::filter(.data$date >= "1980-01-01") %>% dplyr::rename(precipitation = "prcp") - rustys <- read.csv(file.path(path, 'PortalData/Weather/Rustys_regional_weather.csv'), - na.strings = c(""), header = TRUE, stringsAsFactors = FALSE) %>% - dplyr::group_by(.data$year, .data$month, .data$day) %>% - dplyr::summarize(mintemp = min(.data$templow), - maxtemp = max(.data$temphigh), - meantemp = mean(.data$tempavg), - precipitation = sum(.data$preciptotal)) %>% - dplyr::select(dplyr::all_of(c("year", "month", "day", "mintemp", "maxtemp", "meantemp","precipitation"))) %>% - dplyr::arrange(.data$year,.data$month, .data$day) - - rodeo <- read.csv(file.path(path, 'PortalData/Weather/Rodeo_regional_weather.csv'), + region1 <- read.csv(file.path(path, 'PortalData/Weather/Rodeo_regional_weather.csv'), na.strings = c(""), header = TRUE, stringsAsFactors = FALSE) %>% dplyr::group_by(.data$year, .data$month, .data$day) %>% dplyr::summarize(mintemp = min(.data$templow), @@ -197,18 +187,6 @@ fill_missing_weather <- function(weather, path = get_default_data_path()) dplyr::select(dplyr::all_of(c("year", "month", "day", "mintemp", "maxtemp", "meantemp","precipitation"))) %>% dplyr::arrange(.data$year,.data$month, .data$day) - region1 <- dplyr::full_join(rodeo, rustys, by = c("year", "month", "day")) %>% - dplyr::group_by(.data$year, .data$month, .data$day) %>% - dplyr::rowwise() %>% - dplyr::mutate(mintemp = mean(c(.data$mintemp.y, .data$mintemp.x), na.rm=TRUE), - maxtemp = mean(c(.data$maxtemp.y, .data$maxtemp.x), na.rm=TRUE), - meantemp = mean(c(.data$meantemp.y, .data$meantemp.x), na.rm=TRUE), - precipitation = mean(c(.data$precipitation.y, .data$precipitation.x), na.rm=TRUE)) %>% - dplyr::ungroup() %>% - dplyr::filter(!(is.na(.data$mintemp) & is.na(.data$maxtemp) & - is.na(.data$meantemp) & is.na(.data$precipitation))) %>% - dplyr::select(dplyr::all_of(c("year", "month", "day", "precipitation", "mintemp", "maxtemp", "meantemp"))) - region2 <- dplyr::full_join(portal4sw, sansimon, by = c("date", "year", "month", "day")) %>% dplyr::group_by(.data$year, .data$month, .data$day, .data$date) %>% dplyr::rowwise() %>% diff --git a/R/portalr-package.R b/R/portalr-package.R index a4b30c5a..3c7a43d3 100644 --- a/R/portalr-package.R +++ b/R/portalr-package.R @@ -1,10 +1,9 @@ +#' @keywords internal #' @title Creates summaries of the Portal data #' #' @description This package is designed to be an interface to the Portal data, which resides online at \url{https://github.com/weecology/portalData}. Its contains a set of functions to download, clean, and summarize the data. #' #' @name portalr -#' @docType package -#' @keywords package #' #' @importFrom lubridate "%m+%" #' @importFrom rlang "!!" "!!!" ":=" .data @@ -12,12 +11,12 @@ #' @importFrom stats median na.omit #' @importFrom httr content GET stop_for_status -NULL +"_PACKAGE" ## quiets concerns of R CMD check re: variables used in NSE functions if (getRversion() >= "2.15.1") utils::globalVariables( - c(".", "n") - ) + c(".", "n") +) #' @title Return Citation for Portal Data #' @@ -25,7 +24,7 @@ if (getRversion() >= "2.15.1") utils::globalVariables( #' @export get_dataset_citation <- function() { - path <- system.file("CITATION-PORTAL-DATA", - package = "portalr", mustWork = TRUE) - utils::readCitationFile(path) + path <- system.file("CITATION-PORTAL-DATA", + package = "portalr", mustWork = TRUE) + utils::readCitationFile(path) } diff --git a/README.Rmd b/README.Rmd index cb92c421..78477003 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,7 +19,7 @@ library(portalr) [![R-CMD-check](https://github.com/weecology/portalr/workflows/R-CMD-check/badge.svg)](https://github.com/weecology/portalr/actions) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/weecology/portalr/main/LICENSE) -[![Coverage status](https://codecov.io/gh/weecology/portalr/branch/main/graph/badge.svg)](https://codecov.io/github/weecology/portalr?branch=main) +[![Coverage status](https://codecov.io/gh/weecology/portalr/branch/main/graph/badge.svg)](https://app.codecov.io/github/weecology/portalr?branch=main) [![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/portalr)](https://CRAN.R-project.org/package=portalr) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1429290.svg)](https://doi.org/10.5281/zenodo.1429290) diff --git a/man/load_datafile.Rd b/man/load_datafile.Rd index f3186816..fcae1c94 100644 --- a/man/load_datafile.Rd +++ b/man/load_datafile.Rd @@ -18,8 +18,8 @@ load_datafile( \item{na.strings}{a character vector of strings which are to be interpreted as \code{\link{NA}} values. Blank fields are also considered to be missing values in logical, integer, numeric and - complex fields. Note that the test happens \emph{after} - white space is stripped from the input, so \code{na.strings} + complex fields. Note that the test happens \emph{after} + white space is stripped from the input, so \code{na.strings} values may need their own white space stripped in advance.} \item{path}{either the file path that contains the PortalData folder or diff --git a/man/portalr.Rd b/man/portalr.Rd index ad9310c0..81ad3b8c 100644 --- a/man/portalr.Rd +++ b/man/portalr.Rd @@ -3,8 +3,39 @@ \docType{package} \name{portalr} \alias{portalr} +\alias{portalr-package} \title{Creates summaries of the Portal data} \description{ This package is designed to be an interface to the Portal data, which resides online at \url{https://github.com/weecology/portalData}. Its contains a set of functions to download, clean, and summarize the data. } -\keyword{package} +\seealso{ +Useful links: +\itemize{ + \item \url{https://weecology.github.io/portalr/} + \item \url{https://github.com/weecology/portalr} + \item Report bugs at \url{https://github.com/weecology/portalr/issues} +} + +} +\author{ +\strong{Maintainer}: Glenda M. Yenni \email{glenda@weecology.org} (\href{https://orcid.org/0000-0001-6969-1848}{ORCID}) + +Authors: +\itemize{ + \item Hao Ye (\href{https://orcid.org/0000-0002-8630-1458}{ORCID}) + \item Erica M. Christensen (\href{https://orcid.org/0000-0002-5635-2502}{ORCID}) + \item Juniper L. Simonis (\href{https://orcid.org/0000-0001-9798-0460}{ORCID}) + \item Ellen K. Bledsoe (\href{https://orcid.org/0000-0002-3629-7235}{ORCID}) + \item Renata M. Diaz (\href{https://orcid.org/0000-0003-0803-4734}{ORCID}) + \item Shawn D. Taylor (\href{https://orcid.org/0000-0002-6178-6903}{ORCID}) + \item Ethan P, White (\href{https://orcid.org/0000-0001-6728-7745}{ORCID}) + \item S.K. Morgan Ernest (\href{https://orcid.org/0000-0002-6026-8530}{ORCID}) +} + +Other contributors: +\itemize{ + \item Weecology [copyright holder] +} + +} +\keyword{internal}