From d9b6aeae8b68e3315c06727cddc3aa2aad346065 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Wed, 4 May 2016 16:57:08 -0700 Subject: [PATCH] fix #155 - fix to argo functions for the file param and box input removed Remotes install of geojsonio need to import scale_x_date from ggplot2 removed commented out code form ncdc_plot --- DESCRIPTION | 3 +-- NAMESPACE | 2 +- R/argo.R | 5 +++-- R/ncdc_plot.r | 8 ++++---- R/ncdc_stations.r | 8 ++++++++ R/rnoaa-package.r | 28 ++++++++++++++-------------- man/ncdc_plot.Rd | 4 ++-- man/ncdc_stations.Rd | 8 ++++++++ man/rnoaa-package.Rd | 14 +++++++------- 9 files changed, 48 insertions(+), 32 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 82082102..3ffd1bd8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,7 @@ Description: Client for many 'NOAA' data sources including the 'NCDC' climate for 'NOAA' sea ice data, the 'NOAA' severe weather inventory, 'NOAA' Historical Observing 'Metadata' Repository ('HOMR') data, 'NOAA' storm data via 'IBTrACS', tornado data via the 'NOAA' storm prediction center, and more. -Version: 0.5.2.9998 +Version: 0.5.5.9000 License: MIT + file LICENSE Authors@R: c( person("Scott", "Chamberlain", role = c("aut","cre"), email = "myrmecocystus@gmail.com"), @@ -44,5 +44,4 @@ Suggests: lawn, rgdal, covr -Remotes: ropensci/geojsonio RoxygenNote: 5.0.1 diff --git a/NAMESPACE b/NAMESPACE index 4075c590..8d2a0ab8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -120,7 +120,7 @@ importFrom(ggplot2,ggplot) importFrom(ggplot2,guide_legend) importFrom(ggplot2,guides) importFrom(ggplot2,labs) -importFrom(ggplot2,scale_x_datetime) +importFrom(ggplot2,scale_x_date) importFrom(ggplot2,theme) importFrom(ggplot2,theme_bw) importFrom(httr,GET) diff --git a/R/argo.R b/R/argo.R index 9b6be8ae..2785599b 100644 --- a/R/argo.R +++ b/R/argo.R @@ -11,12 +11,13 @@ argo_search <- function(func = NULL, of = NULL, qwmo = NULL, wmo = NULL, box=NUL pres_qc = NULL, temp_qc = NULL, psal_qc = NULL, doxy_qc = NULL, ticket = NULL, limit = 10, ...) { - args <- noaa_compact(list(get = func, of = of, qwmo = qwmo, wmo = wmo, file = file, + if (!is.null(box)) box <- paste0(box, collapse = ",") + args <- noaa_compact(list(get = func, of = of, qwmo = qwmo, wmo = wmo, box = box, area = area, around = around, year = year, yearmin = yearmin, yearmax = yearmax, month = month, monthmin = monthmin, monthmax = monthmax, lr = lr, from = from, to = to, dmode = dmode, pres_qc = pres_qc, temp_qc = temp_qc, psal_qc = psal_qc, doxy_qc = doxy_qc, ticket = ticket, limit = limit)) - res <- argo_GET(argo_api(), args, ...) + res <- argo_GET(url = argo_api(), args, ...) jsonlite::fromJSON(utcf8(res)) } diff --git a/R/ncdc_plot.r b/R/ncdc_plot.r index 4624f012..e056391f 100644 --- a/R/ncdc_plot.r +++ b/R/ncdc_plot.r @@ -2,8 +2,8 @@ #' #' @export #' @param ... Input noaa object or objects. -#' @param breaks Regularly spaced date breaks for x-axis. See examples for usage. -#' See \code{\link{date_breaks}}. Default: \code{NULL} (uses ggplot2 default break +#' @param breaks Regularly spaced date breaks for x-axis. See examples for usage. +#' See \code{\link{date_breaks}}. Default: \code{NULL} (uses ggplot2 default break #' sformatting) #' @param dateformat Date format using standard POSIX specification for labels on #' x-axis. See \code{\link{date_format}} @@ -11,7 +11,7 @@ #' @details #' This function accepts directly output from the \code{\link[rnoaa]{ncdc}} function, #' not other functions. -#' +#' #' This is a simple wrapper function around some ggplot2 code. There is indeed a lot you #' can modify in your plots, so this function just does some basic stuff. Look at the internals #' for what the function does. @@ -81,7 +81,7 @@ plot_template <- function(df, breaks, dateformat) { ) if (!is.null(breaks)) { c(tt, scale_x_date(date_breaks = breaks, date_labels = dateformat)) - #c(tt, scale_x_datetime(breaks = date_breaks(breaks), labels = date_format(dateformat))) + } else { tt } diff --git a/R/ncdc_stations.r b/R/ncdc_stations.r index 71f48f36..1b0c9d81 100644 --- a/R/ncdc_stations.r +++ b/R/ncdc_stations.r @@ -21,6 +21,14 @@ #' #' # Get metadata on a single station #' ncdc_stations(stationid='COOP:010008') +#' +#' # For many stations use lapply or similar +#' lapply(c("COOP:010008", "COOP:010063", "COOP:010116"), function(z) { +#' ncdc_stations( +#' startdate = "2013-01-01", +#' enddate = "2014-11-01", +#' stationid = z) +#' }$data) #' #' # Displays all stations within GHCN-Daily (100 Stations per page limit) #' ncdc_stations(datasetid='GHCND') diff --git a/R/rnoaa-package.r b/R/rnoaa-package.r index 5808818a..fc604880 100644 --- a/R/rnoaa-package.r +++ b/R/rnoaa-package.r @@ -1,16 +1,16 @@ #' @title rnoaa -#' +#' #' @description rnoaa is an R interface to NOAA climate data. #' -#' @section Data Sources: -#' Many functions in this package interact with the National Climatic Data -#' Center application programming interface (API) at +#' @section Data Sources: +#' Many functions in this package interact with the National Climatic Data +#' Center application programming interface (API) at #' http://www.ncdc.noaa.gov/cdo-web/webservices/v2, all of #' which functions start with \code{ncdc_}. An access token, or API key, is required to use all -#' the \code{ncdc_} functions. The key is required by NOAA, not us. Go to the link given above +#' the \code{ncdc_} functions. The key is required by NOAA, not us. Go to the link given above #' to get an API key. #' -#' More NOAA data sources are being added through time. Data sources and their +#' More NOAA data sources are being added through time. Data sources and their #' function prefixes are: #' #' \itemize{ @@ -27,23 +27,23 @@ #' \item \code{argo_*} - Argo buoys #' \item \code{coops_search} - NOAA CO-OPS - tides and currents data #' } -#' +#' #' @section A note about NCDF data: -#' +#' #' Functions to work with buoy data use netcdf files. You'll need the \code{ncdf4} -#' package for those functions, and those only. \code{ncdf4} is in Suggests in -#' this package, meaning you only need \code{ncdf4} if you are using the buoy +#' package for those functions, and those only. \code{ncdf4} is in Suggests in +#' this package, meaning you only need \code{ncdf4} if you are using the buoy #' functions. You'll get an informative error telling you to install \code{ncdf4} #' if you don't have it and you try to use the buoy functions. -#' +#' #' @importFrom methods is #' @importFrom stats var setNames complete.cases -#' @importFrom utils head download.file read.csv read.delim read.fwf read.table +#' @importFrom utils head download.file read.csv read.delim read.fwf read.table #' write.csv untar unzip #' @importFrom lubridate ymd year today month #' @importFrom scales date_breaks date_format -#' @importFrom ggplot2 ggplot aes facet_wrap theme theme_bw geom_line labs -#' guides guide_legend fortify scale_x_datetime element_blank +#' @importFrom ggplot2 ggplot aes facet_wrap theme theme_bw geom_line labs +#' guides guide_legend fortify scale_x_date element_blank #' @importFrom httr GET add_headers content warn_for_status stop_for_status #' write_disk parse_url build_url http_status #' @importFrom XML xpathSApply xpathApply xmlValue xmlParse xmlToList htmlParse diff --git a/man/ncdc_plot.Rd b/man/ncdc_plot.Rd index 152c042c..f8531f2f 100644 --- a/man/ncdc_plot.Rd +++ b/man/ncdc_plot.Rd @@ -9,8 +9,8 @@ ncdc_plot(..., breaks = NULL, dateformat = "\%d/\%m/\%y") \arguments{ \item{...}{Input noaa object or objects.} -\item{breaks}{Regularly spaced date breaks for x-axis. See examples for usage. -See \code{\link{date_breaks}}. Default: \code{NULL} (uses ggplot2 default break +\item{breaks}{Regularly spaced date breaks for x-axis. See examples for usage. +See \code{\link{date_breaks}}. Default: \code{NULL} (uses ggplot2 default break sformatting)} \item{dateformat}{Date format using standard POSIX specification for labels on diff --git a/man/ncdc_stations.Rd b/man/ncdc_stations.Rd index a4ebbff7..7057b250 100644 --- a/man/ncdc_stations.Rd +++ b/man/ncdc_stations.Rd @@ -88,6 +88,14 @@ ncdc_stations(limit=5) # Get metadata on a single station ncdc_stations(stationid='COOP:010008') +# For many stations use lapply or similar +lapply(c("COOP:010008", "COOP:010063", "COOP:010116"), function(z) { + ncdc_stations( + startdate = "2013-01-01", + enddate = "2014-11-01", + stationid = z) +}$data) + # Displays all stations within GHCN-Daily (100 Stations per page limit) ncdc_stations(datasetid='GHCND') ncdc_stations(datasetid=c('GHCND', 'ANNUAL')) diff --git a/man/rnoaa-package.Rd b/man/rnoaa-package.Rd index bd0596a1..d975ffae 100644 --- a/man/rnoaa-package.Rd +++ b/man/rnoaa-package.Rd @@ -9,15 +9,15 @@ rnoaa is an R interface to NOAA climate data. } \section{Data Sources}{ - -Many functions in this package interact with the National Climatic Data -Center application programming interface (API) at + +Many functions in this package interact with the National Climatic Data +Center application programming interface (API) at http://www.ncdc.noaa.gov/cdo-web/webservices/v2, all of which functions start with \code{ncdc_}. An access token, or API key, is required to use all -the \code{ncdc_} functions. The key is required by NOAA, not us. Go to the link given above +the \code{ncdc_} functions. The key is required by NOAA, not us. Go to the link given above to get an API key. -More NOAA data sources are being added through time. Data sources and their +More NOAA data sources are being added through time. Data sources and their function prefixes are: \itemize{ @@ -40,8 +40,8 @@ function prefixes are: Functions to work with buoy data use netcdf files. You'll need the \code{ncdf4} -package for those functions, and those only. \code{ncdf4} is in Suggests in -this package, meaning you only need \code{ncdf4} if you are using the buoy +package for those functions, and those only. \code{ncdf4} is in Suggests in +this package, meaning you only need \code{ncdf4} if you are using the buoy functions. You'll get an informative error telling you to install \code{ncdf4} if you don't have it and you try to use the buoy functions. }