| [[,argoFloats-method {argoFloats} | R Documentation |
Look up a Value Within an argoFloats Object
Description
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”.
Usage
## S4 method for signature 'argoFloats'
x[[i, j, ...]]
Arguments
x |
an |
i |
a character value that specifies the item to be looked up; see “Details”. |
j |
supplemental index value, used for some |
... |
ignored. |
Details
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
iis"metadata"then themetadataslot ofxis returned.Otherwise, if
iis"data"then thedataslot ofxis returned.Otherwise, if
iis"cycle"then a character vector of the cycle numbers is returned.Otherwise, if
iis"processingLog"then theprocessingLogslot ofxis returned.Otherwise, if
iis"ID"then a character vector of the ID numbers is returned.Otherwise, the following steps are taken, depending on
type.
If
typeis"index", i.e. ifxwas created withgetIndex()or withsubset,argoFloats-method()acting on the result ofgetIndex(), then:If
iis numeric andjis unspecified, theniis taken to be an index that identifies the row(s) of the data frame that was constructed bygetIndex()based on the remote index file downloaded from the Argo server. This has elementsfilefor the remote file name,datefor the date of the entry,latitudeandlongitudefor the float position, etc.If
iis the name of an item in themetadataslot, then that item is returned. The choices are:"destdir","destfileRda","filename","ftpRoot","header","server","type", and"url".Otherwise, if
iis the name of an item in thedataslot, 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 thedataslot ofxis returned. (For the possible names, see the previous item in this sub-list.)Otherwise, if
iis an integer, then thei-th row of theindexitem in thedataslot 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
iis"ID"then the return value is developed from theindex$fileitem within thedataslot ofx, in one of three cases:If
jis 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
jis numeric, then the return value is a subset of the ID codes, as indexed byj.Otherwise, an error is reported.
If
iis"length", the number of remote files pointed to by the index is returned.
Otherwise, if
typeis"profiles", i.e. ifxwas created withgetProfiles(), then:If
iis numeric andjis unspecified, then return the local file name(s) that are identified by usingias an index.If
iis the name of an item in themetadataslot, then that item is returned. The choices are:"type"and"destdir".Otherwise, if
iis the name of an item in thedataslot, then that item is returned. There is only one choice:"file".If
iis"length", the number of local file names that were downloaded bygetProfiles()is returned.
Otherwise, if
typeis"argos", i.e. ifxwas created withreadProfiles(), then:If
iis equal to"argos", andjis unspecified, then a list holding the oce::argo objects stored withinxis returned.If
iis equal to"argos", andjis provided, then the associated oce::argo object is returned.If
iis numeric andjis unspecified, then return the argo objects identified by usingias an index.If
iis the name of an item in themetadataslot, then that item is returned. There is only choice,"type".Otherwise, if
iis the name of an item in thedataslot, then that item is returned as a named list. (At present, there is only one choice:"argos".)Otherwise, if
iis"length"then the number of oce-type argo objects inxis returned.Otherwise, if
iis a character value then it is taken to be an item within themetadataordataslots of the argo objects stored inx, and the returned value is a list containing that information with one (unnamed) item per profile. Ifjis provided and equal to"byLevel", then the items from themetadataare 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 levelOtherwise, NULL is reported.
Otherwise, an error is reported.
Value
the indicated item, or NULL if it is neither stored within the first argument nor computable from its contents.
Author(s)
Dan Kelley
References
Kelley, D. E., Harbin, J., & Richards, C. (2021). argoFloats: An R package for analyzing Argo data. Frontiers in Marine Science, (8), 636922. doi:10.3389/fmars.2021.635922
Examples
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"]])