subset,section-method {oce} | R Documentation

## Subset a Section Object

### Description

Return a subset of a section object.

### Usage

    ## S4 method for signature 'section'
    subset(x, subset, ...)

### Arguments

`x` | A `section` object, i.e. one inheriting from `section-class`.
`subset` | 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 `indices`. See “Details”.

### Details

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 `subset` argument, while the second is handled if `...` contains a vector named `indices`. Either `subset` or `indices` must be provided, but not both.

In the "subset" method, `subset` indicates 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 `distance` 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). If either `longitude` or `latitude` is given, then stations are selected according to the stated condition (Example 2). If `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 stored within `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 profile.

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.

### Value

A `section-class` object.

### Author(s)

Dan Kelley

### See Also

Other functions that subset `oce` objects: `subset,adp-method`, `subset,adv-method`, `subset,amsr-method`, `subset,argo-method`, `subset,cm-method`, `subset,coastline-method`, `subset,ctd-method`, `subset,echosounder-method`, `subset,lobo-method`, `subset,met-method`, `subset,oce-method`, `subset,odf-method`, `subset,rsk-method`, `subset,sealevel-method`, `subset,topo-method`

Other things related to `section` data: `[[,section-method`, `[[<-,section-method`, `as.section`, `handleFlags,section-method`, `plot,section-method`, `read.section`, `section-class`, `sectionAddStation`, `sectionGrid`, `sectionSmooth`, `sectionSort`, `section`, `summary,section-method`

### Examples

    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"]]))))

[Package oce version 0.9-22 Index]