[[,argoFloats-method | R Documentation |
This function provides an easy way to look up values within an argoFloats
object, without the need to know the exact structure of the data. The action
taken by [[
depends on the type
element in the metadata
slot of
the object (which is set by the function that created the object), on the
value of i
and, in some cases, on the value of j
; see “Details”.
## S4 method for signature 'argoFloats'
x[[i, j, ...]]
x |
an |
i |
a character value that specifies the item to be looked up; see “Details”. |
j |
supplemental index value, used for some |
... |
ignored. |
There are several possibilities, depending on the object type
, as
listed below. Note that these possibilities are checked in the
order listed here.
For all object types:
If i
is "metadata"
then the metadata
slot of x
is returned.
Otherwise, if i
is "data"
then the data
slot of x
is returned.
Otherwise, if i
is "cycle"
then a character vector of the cycle
numbers is returned.
Otherwise, if i
is "processingLog"
then the processingLog
slot of
x
is returned.
Otherwise, if i
is "ID"
then a character vector of the ID numbers
is returned.
Otherwise, the following steps are taken, depending on type
.
If type
is "index"
, i.e. if x
was created with getIndex()
or with subset,argoFloats-method()
acting on the result of getIndex()
,
then:
If i
is numeric and j
is unspecified, then i
is taken to
be an index that identifies the row(s) of the data frame that
was constructed by getIndex()
based on the remote index file
downloaded from the Argo server. This has elements file
for
the remote file name, date
for the date of the entry, latitude
and longitude
for the float position, etc.
If i
is the name of an item in the metadata
slot, then that item
is returned. The choices are:
"destdir"
, "destfileRda"
, "filename"
, "ftpRoot"
, "header"
,
"server"
, "type"
, and "url"
.
Otherwise, if i
is the name of an item in the data
slot, then that item
is returned. The choices are:
"date"
, "date_update"
, "file"
, "institution"
, "latitude"
,
"longitude"
, "ocean"
, and "profiler_type"
. Note that "time"
and
"time_update"
may be used as synonyms for "date"
and "date_update"
.
Otherwise, if i=="index"
then that item from the data
slot of x
is returned.
(For the possible names, see the previous item in this sub-list.)
Otherwise, if i
is an integer, then the i
-th row of the index
item in
the data
slot is returned. This is a good way to learn the
longitude and latitude of the profile, the file name on the server,
etc.
Otherwise, if i
is "ID"
then the return value is developed from the
index$file
item within the data
slot of x
, in one of three cases:
If j
is not supplied, the return value is a vector holding the
identifiers (character codes for numbers) for all the data files
referred to in the index.
Otherwise, if j
is numeric, then the return value is a subset of
the ID codes, as indexed by j
.
Otherwise, an error is reported.
If i
is "length"
, the number of remote files pointed to by the index
is returned.
Otherwise, if type
is "profiles"
, i.e. if x
was created with getProfiles()
, then:
If i
is numeric and j
is unspecified, then return the local file name(s)
that are identified by using i
as an index.
If i
is the name of an item in the metadata
slot, then that item
is returned. The choices are:
"type"
and "destdir"
.
Otherwise, if i
is the name of an item in the data
slot, then that item
is returned. There is only one choice: "file"
.
If i
is "length"
, the number of local file names that were downloaded
by getProfiles()
is returned.
Otherwise, if type
is "argos"
, i.e. if x
was created with readProfiles()
, then:
If i
is equal to "argos"
, and j
is unspecified, then a list
holding the oce::argo objects stored within x
is returned.
If i
is equal to "argos"
, and j
is provided, then the associated
oce::argo object is returned.
If i
is numeric and j
is unspecified, then return the argo objects identified
by using i
as an index.
If i
is the name of an item in the metadata
slot, then that item
is returned. There is only choice, "type"
.
Otherwise, if i
is the name of an item in the data
slot, then that item
is returned as a named list. (At present, there is only one choice: "argos"
.)
Otherwise, if i
is "length"
then the number of oce-type argo objects in x
is returned.
Otherwise, if i
is a character value then it is taken to be
an item within the metadata
or data
slots of the argo objects
stored in x
, and the returned value is a list containing that
information with one (unnamed) item per profile.
If j
is provided
and equal to "byLevel"
, then the items from the metadata
are
repeated (if necessary) and formed into matrix or vector of the same
shape as the "pressure"
field; this can be convenient for computations
involving items that only occur once per profile, such as "longitude"
,
but it should not be used for items that are not level-specific, such
as the various "HISTORY_*"
elements, which apply to a dataset, not to
a level
Otherwise, NULL is reported.
Otherwise, an error is reported.
the indicated item, or NULL if it is neither stored within the first argument nor computable from its contents.
Dan Kelley
Kelley, D. E., Harbin, J., & Richards, C. (2021). argoFloats: An R package for analyzing Argo data. Frontiers in Marine Science, (8), 636922. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3389/fmars.2021.635922")}
data(index)
# Full remote filename for first two item in index
paste0(index[["server"]], "/dac/", index[["cycle", 1:2]])
# File names and geographical locations of first 5 items in index
index5 <- subset(index, 1:5)
data.frame(file=gsub(".*/", "", index5[["file"]][1]),
lon=index5[["longitude"]],
lat=index5[["latitude"]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.