Learn R Programming

vectools (version 0.3.0)

45_objtag_methods: objtag Methods

Description

Element-level formatting functions for object arrays.

Usage

# S3 method for ObjectArray
objtag(v, …)
# S3 method for NestMatrix
objtag(v, …)
# S3 method for PartMatrix
objtag(v, …)
# S3 method for SectMatrix
objtag(v, …)
# S3 method for MatrixArray
objtag(v, …)

# S3 method for Zero objtag(v, …)

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

# S3 method for default objtag(v, …)

# S3 method for GeomObject objtag(v, …) # S3 method for GeomArray objtag(v, …) # S3 method for RImage objtag(im, …) # S3 method for ImageArray objtag(im, …)

Arguments

im, v

An object.

Ignored.

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.

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.

See Also

format.ObjectArray

Examples

Run this code
# NOT RUN {
#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
# }

Run the code above in your browser using DataLab