Skip to content

Commit

Permalink
can now do e.g. argo[["profile", 2:3]]
Browse files Browse the repository at this point in the history
This is equivalent to

subset(argo, profile %in% 2:3)
  • Loading branch information
dankelley committed May 7, 2019
1 parent 1144174 commit 0910220
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions R/argo.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ NULL
#'
#'\itemize{
#'
#' \item If \code{i} is \code{"profile"} and \code{j} is an integer vector,
#' then an argo object is returned, as specified by \code{j}. For example,
#' \code{argo[["profile", 2:5]]} is equivalent to
#' \code{subset(argo, profile \%in\% 2:5)}.
#'
#' \item If \code{i} is \code{"CT"}, then
#' Conservative Temperature is returned, as computed with
#' \code{\link[gsw]{gsw_CT_from_t}(SA, t, p)}, where
Expand Down Expand Up @@ -137,6 +142,11 @@ setMethod(f="[[",
signature(x="argo", i="ANY", j="ANY"),
definition=function(x, i, j, ...) {
res <- NULL
if (i == "profile") {
if (missing(j))
stop("must provide an integer vector to access, e.g. argo[[\"profile\", 1:3]]")
return(subset(x, profile %in% j))
}
if (i %in% c("CT", "N2", "SA", "sigmaTheta", "theta")) {
## FIXME: should we prefer e.g. salinityAdjusted or salinity?
names <- names(x@data)
Expand Down
5 changes: 5 additions & 0 deletions man/sub-sub-argo-method.Rd

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

0 comments on commit 0910220

Please sign in to comment.