diff --git a/R/argo.R b/R/argo.R index a87bbaf4a6..c186d770b3 100644 --- a/R/argo.R +++ b/R/argo.R @@ -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 @@ -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) diff --git a/man/sub-sub-argo-method.Rd b/man/sub-sub-argo-method.Rd index 9b4dbc99b8..703b7e061c 100644 --- a/man/sub-sub-argo-method.Rd +++ b/man/sub-sub-argo-method.Rd @@ -44,6 +44,11 @@ otherwise, and similar for temperature and pressure. \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