45_objtag_methods: objtag Methods

Description Usage Arguments Details Value See Also Examples

Description

Element-level formatting functions for object arrays.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## S3 method for class 'ObjectArray'
objtag(v, ...)
## S3 method for class 'NestMatrix'
objtag(v, ...)
## S3 method for class 'PartMatrix'
objtag(v, ...)
## S3 method for class 'SectMatrix'
objtag(v, ...)
## S3 method for class 'MatrixArray'
objtag(v, ...)

## S3 method for class 'Zero'
objtag(v, ...)

## S3 method for class 'function'
objtag(v, ...)
## S3 method for class 'list'
objtag(v, ...)
## S3 method for class 'data.frame'
objtag(v, ...)
## S3 method for class 'matrix'
objtag(v, ...)

## Default S3 method:
objtag(v, ...)

## S3 method for class 'GeomObject'
objtag(v, ...)
## S3 method for class 'GeomArray'
objtag(v, ...)
## S3 method for class 'RImage'
objtag(im, ...)
## S3 method for class 'ImageArray'
objtag(im, ...)

Arguments

im, v

An object.

...

Ignored.

Details

These functions map an object to a single compact string, regardless of the length of the object.

The format method for ObjectArray calls the objtag function for each of its elements.

To format an object of a different class, you need to write an (S3) objtag method for that class.

Value

Each method returns a single compact string.
(i.e. A length-one character vector, that's relatively short).

If you write a new objtag method, it should do the same.

See Also

format.ObjectArray

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#simple classes
alphabet.1 <- function ()
    structure (LETTERS, class="alphabet.1")
alphabet.2 <- function ()
    structure (sample (LETTERS), class="alphabet.2")

#simple 2x2 ObjectArray
x <- ObjectArray (c (2, 2) )
x [[1, 1]] <- alphabet.1 ()
x [[2, 1]] <- alphabet.1 ()
x [[1, 2]] <- alphabet.2 ()
x [[2, 2]] <- alphabet.2 ()

#printed with default formatting
x

#objtag methods
objtag.alphabet.1 <- function (x)
    paste ("<A1 ", x [1], ":", x [26], ">", sep="")
objtag.alphabet.2 <- function (x)
    paste ("<A2 ", x [1], ":", x [26], ">", sep="")

#reprinted with custom formatting
x

vectools documentation built on June 7, 2021, 9:08 a.m.