Learn R Programming

omnibus (version 1.2.12)

corner: Corner of a matrix or data frame

Description

Return a corner of a matrix or data frame (i.e., upper left, upper right, lower left, lower right).

Usage

corner(x, corner = 1, size = 5)

Value

A matrix or data frame.

Arguments

x

Data frame or matrix.

corner

Integer in the set 1, 2, 3, 4 or character in the set 'topleft', 'topright', 'bottomleft', 'bottomright' or in the set 'tl', 'tr', 'bl', 'br'. Indicates which corner to return. Integers 1, 2, 3 and 4 correspond to top left, top right, bottom left, and bottom right corners. The default is 1, the top left corner.

size

Positive integer, number of rows and columns to return. If there are fewer columns/rows than indicated then all columns/rows are returned.

See Also

Examples

Run this code
x <- matrix(1:120, ncol=12, nrow=10)
x
corner(x, 1)
corner(x, 2)
corner(x, 3)
corner(x, 4)

Run the code above in your browser using DataLab