Skip to content

Commit

Permalink
New function: showStock()
Browse files Browse the repository at this point in the history
  • Loading branch information
Arni Magnusson committed Nov 10, 2016
1 parent aba3ea7 commit 94fb3e1
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 4 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: icesSLD
Version: 0.0-0
Date: 2016-09-12
Version: 1.0-0
Date: 2016-11-10
Title: Stock List Database Web Services
Authors@R: c(person("Colin", "Millar", role="aut"),
person("Scott", "Large", role=c("aut","cre"), email="scott.large@ices.dk"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(getSLD)
export(showStock)
importFrom(curl,curl)
importFrom(curl,handle_setheaders)
importFrom(curl,new_handle)
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--------------------------------------------------------------------------------
icesSLD 1.0-0 (2016-11-10)
--------------------------------------------------------------------------------
o Initial release, with two functions: getSLD() and showStock().
2 changes: 2 additions & 0 deletions R/getSLD.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#'
#' @return A data frame.
#'
#' \code{\link{showStock}} shows stock list data for one stock.
#'
#' \code{\link{icesSLD-package}} gives an overview of the package.
#'
#' @examples
Expand Down
3 changes: 2 additions & 1 deletion R/icesSLD-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#' @details
#' \emph{Get dataset:}
#' \tabular{ll}{
#' \code{\link{getSLD}} \tab stock list
#' \code{\link{getSLD}} \tab full stock list\cr
#' \code{\link{showStock}} \tab one stock
#' }
#'
#' @author Colin Millar, Scott Large, and Arni Magnusson.
Expand Down
34 changes: 34 additions & 0 deletions R/showStock.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#' Show Stock
#'
#' Show stock list data for a given stock, such as expert group, advice group,
#' assessment type, etc.
#'
#' @param stock the stock code, e.g. cod-347d.
#' @param year the active year of the stock list, e.g. 2016, or NULL to get the
#' most recent year available.
#' @param quiet whether to suppress printing to screen.
#'
#' @return A single-row data frame, printed to screen with
#' \code{print.simple.list} unless quiet is TRUE.
#'
#' \code{\link{getSLD}} gets all stock list data.
#'
#' \code{\link{icesSLD-package}} gives an overview of the package.
#'
#' @examples
#' showStock("sai-icel")
#' cod.347d <- showStock("cod-347d", quiet=TRUE)
#'
#' @export

showStock <- function(stock, year = NULL, quiet = FALSE)
{
sldata <- getSLD()
out <- sldata[sldata$StockCode == stock,]
if (is.null(year))
year <- max(out$ActiveYear)
out <- out[out$ActiveYear == year,]
if (!quiet)
print.simple.list(out)
invisible(out)
}
2 changes: 2 additions & 0 deletions man/getSLD.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/icesSLD-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions man/showStock.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 94fb3e1

Please sign in to comment.