The S7 scheme is used for objects created by functions in the mooring package.

The functions mooring(), segmentize() and knockdown() all deal with moorings, and they return an object that is named so that other functions will know how to deal with the information. Moorings consist of what are called “elements” in the package, and these are created with a suite of specialized functions. In common work, the main element-creating functions are anchor() for creating anchors, wire() for creating wires, instrument() for creating instruments, and float() for creating floats. Consult the “see also” section of the documentation for any of these functions, to discover other element-creating functions.

Some examples may clarify. First, we create an anchor element, and find its contents.

## Loading required package: S7
a <- anchor()

To see it’s contents, simply type its name in an interactive console:

a
## <mooring::anchorS7>
##  @ model       : chr "1 Railway Wheel"
##  @ buoyancy    : num -350
##  @ height      : num 0.15
##  @ area        : num 0
##  @ CD          : num 1.3
##  @ source      : chr "Dewey"
##  @ originalName: chr "1 Railway Wheel"
##  @ x           : num 0
##  @ x0          : num 0
##  @ z           : num 0
##  @ z0          : num 0
##  @ phi         : num 0
##  @ tau         : num 0
##  @ group       : num 0

The individual components can be accessed with the @ syntax used by S7. For example, the buoyancy (the negative of the ‘weight’ in water, expressed in kg) as

a@buoyancy
## [1] -350

You may also alter the components easily; e.g. the following reduces the height of this anchor to zero.

a@height <- 0
a
## <mooring::anchorS7>
##  @ model       : chr "1 Railway Wheel"
##  @ buoyancy    : num -350
##  @ height      : num 0
##  @ area        : num 0
##  @ CD          : num 1.3
##  @ source      : chr "Dewey"
##  @ originalName: chr "1 Railway Wheel"
##  @ x           : num 0
##  @ x0          : num 0
##  @ z           : num 0
##  @ z0          : num 0
##  @ phi         : num 0
##  @ tau         : num 0
##  @ group       : num 0

Using e.g. anchor("?") gives a list of built-in anchor types, and it is not uncommon to construct mooring elements by staring with a known element and changing some quantities.

Turning to moorings, a 4-element case will suffice for illustration.

m <- mooring(anchor(), wire(length = 75), float(), waterDepth = 100)

As the reader has no doubt guessed, the way to find the contents is to name the object.

m
## <mooring::mooringS7>
##  @ elements  :List of 3
##  .. $ : <mooring::floatS7>
##  ..  ..@ model       : chr "Kiel SFS40in"
##  ..  ..@ buoyancy    : num 320
##  ..  ..@ height      : num 1
##  ..  ..@ area        : num 0.785
##  ..  ..@ CD          : num 0.65
##  ..  ..@ source      : chr "Dewey"
##  ..  ..@ originalName: chr "Kiel SFS40in"
##  ..  ..@ x           : num 0
##  ..  ..@ x0          : num 0
##  ..  ..@ z           : num -23.8
##  ..  ..@ z0          : num -23.8
##  ..  ..@ phi         : num 0
##  ..  ..@ tau         : num 320
##  ..  ..@ group       : num 0
##  .. $ : <mooring::wireS7>
##  ..  ..@ model       : chr "1/4in wire/jack"
##  ..  ..@ buoyancy    : num -9.75
##  ..  ..@ height      : num 75
##  ..  ..@ area        : num 0.6
##  ..  ..@ CD          : num 1.3
##  ..  ..@ source      : chr "Dewey"
##  ..  ..@ originalName: chr "1/4 wire/jack"
##  ..  ..@ x           : num 0
##  ..  ..@ x0          : num 0
##  ..  ..@ z           : num -24.8
##  ..  ..@ z0          : num -24.8
##  ..  ..@ phi         : num 0
##  ..  ..@ tau         : num 310
##  ..  ..@ group       : num 0
##  .. $ : <mooring::anchorS7>
##  ..  ..@ model       : chr "1 Railway Wheel"
##  ..  ..@ buoyancy    : num -350
##  ..  ..@ height      : num 0.15
##  ..  ..@ area        : num 0
##  ..  ..@ CD          : num 1.3
##  ..  ..@ source      : chr "Dewey"
##  ..  ..@ originalName: chr "1 Railway Wheel"
##  ..  ..@ x           : num 0
##  ..  ..@ x0          : num 0
##  ..  ..@ z           : num -99.8
##  ..  ..@ z0          : num -99.8
##  ..  ..@ phi         : num 0
##  ..  ..@ tau         : num 310
##  ..  ..@ group       : num 0
##  @ waterDepth: num 100
##  @ u         : num 0
##  @ attributes: list()

The way to get the top element is e.g.

m@elements[[1]]
## <mooring::floatS7>
##  @ model       : chr "Kiel SFS40in"
##  @ buoyancy    : num 320
##  @ height      : num 1
##  @ area        : num 0.785
##  @ CD          : num 0.65
##  @ source      : chr "Dewey"
##  @ originalName: chr "Kiel SFS40in"
##  @ x           : num 0
##  @ x0          : num 0
##  @ z           : num -23.8
##  @ z0          : num -23.8
##  @ phi         : num 0
##  @ tau         : num 320
##  @ group       : num 0