Return a subset of a section object.
an optional indication of either the stations to be kept, or the data to be kept within the stations. See “Details”.
optional arguments, of which only the first is examined. The only
possibility is that this argument be named
This function is used to subset data within the
stations of a section, or to choose a subset of the stations
themselves. The first case is handled with the
while the second is handled if
... contains a vector named
indices must be
provided, but not both.
In the "subset" method,
either stations to be kept, or data to be kept within the stations.
The first step in processing is to check for the presence of certain
key words in the
subset expression. If
is present, then stations are selected according to a condition on the
distance (in km) from the first station to the given station (Example 1).
latitude is given, then
stations are selected according to the stated condition (Example 2).
stationId is present, then selection is in terms of the
station ID (not the sequence number) is used (Example 3). In all of these
cases, stations are either selected in their entirety or dropped
in their entirety.
If none of these keywords is present, then the
subset expression is
evaluated in the context of the
data slot of each of the CTD stations
x. (Note that this slot does not normally
contain any of the keywords that are listed in the previous
paragraph; it does, then odd results may occur.) Each station is examined
in turn, with
subset being evaluated individually in each. The evaluation
produces a logical vector. If that vector has length 1 (Examples 4 and 5)
then the station is retained or discarded, accordingly. If the vector is longer,
then the logical vector is used as a sieve to subsample that individual CTD
In the "indices" method, stations are selected using
indices, which may be a vector of integers that indicate sequence
number, or a logical vector, again indicating which stations to keep.
Other functions that subset
Other things related to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
library(oce) data(section) # 1. Stations within 500 km of the first station starting <- subset(section, distance < 500) # 2. Stations east of 50W east <- subset(section, longitude > (-50)) # 3. Gulf Stream GS <- subset(section, 109 <= stationId & stationId <= 129) # 4. Only stations with more than 5 pressure levels long <- subset(section, length(pressure) > 5) # 5. Only stations that have some data in top 50 dbar surfacing <- subset(section, min(pressure) < 50) # 6. Similar to #4, but done in more detailed way long <- subset(section, indices=unlist(lapply(section[["station"]], function(s) 5 < length(s[["pressure"]]))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.