Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

20_standard_methods

Standard Methods


Description

Length, dim, print, format, head and tail methods for vector-like objects.

Usage

## S3 method for class 'ObjectArray'
length(x)
## S3 method for class 'SectMatrix'
length(x)

## S3 method for class 'ObjectArray'
dim(x)
## S3 method for class 'SectMatrix'
dim(x)

## S3 method for class 'ObjectArray'
dimnames(x)
## S3 method for class 'SectMatrix'
dimnames(x)

## S3 replacement method for class 'ObjectArray'
dimnames(x) <- value
## S3 replacement method for class 'SectMatrix'
dimnames(x) <- value

## S3 method for class 'VectorLike'
print(x, ...)

## S3 method for class 'ObjectArray'
format(x, ...)
## S3 method for class 'SectMatrix'
format(x, na.string="", ...)
## S3 method for class 'ZERO'
format(x, ...)

## S3 method for class 'VectorLike'
head(x, n=6, ...)
## S3 method for class 'VectorLike'
tail(x, n=6, ...)

Arguments

x

A suitable object

.

na.string

String, what to format NAs as.

n

Integer, the number of items.

value

A list of character vectors, matching the dimensions of the object.

...

Ignored.

Details

Note that the dimensions of object arrays and nested matrices are the dimensions of the top level object. However, the dimensions of sectioned matrices (including partitioned matrices) are the dimensions of the combined matrix.

You should also use any functions based on dim or dimnames such as nrow or rownames.

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

The format method for sectioned and partitioned matrices, adds plain-text markup, for separators and section boxes.

Value

Most functions perform the same action as standard R functions.

The format methods return formatted character matrices.

Currently, some of the head, tail functions return formatted character matrices, however, it's possible this may change in the future.

See Also

Examples

x <- matrix (1:100, 10, 10)
pm <- as.PartMatrix (x, 5, c (2, 4, 6, 8) )
nm <- as.NestMatrix (pm)

dim (nm)
dim (pm)

head (nm, 2)
head (pm, 2)

nm
pm

vectools

Advanced Vector Toolkit

v0.2.0
GPL (>= 2)
Authors
Abby Spurdle
Initial release
2020-10-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.