left.R: View left and right parts of objects

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Extension of the functionality of head and tail with functions left and right and combinations hereof. Like head and tail returns the top and bottom parts of an object, left and right return the left- and right-most parts of the object. The functions are primarily oriented toward classes matrix, data.frame, and other matrix-like objects classes but are generic and may be extended to other classes if sensical.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
left(x, ...)

## Default S3 method:
left(x, n = 6L, ...)

## S3 method for class 'matrix'
left(x, n = 6L, ...)

right(x, ...)

## Default S3 method:
right(x, n = 6L, ...)

## S3 method for class 'matrix'
right(x, n = 6L, addcolnums = TRUE, ...)

Arguments

x

The object.

...

Arguments passed to other methods.

n

A single integer. If positive, the n left/right-most parts. If negative, it returns all but the n left/right-most parts.

addcolnums

Logical. Should the column 'fake' numbers be added to the output as column names? Default is TRUE.

Details

top and bot are simply

Value

Usually returns an object of the same class as x but small and more compact.

Author(s)

Modified code from head and tail and the corresponding class-specific methods.
Anders Ellern Bilgrau <anders.ellern.bilgrau (at) gmail.com>

See Also

Main documentation of head and tail

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x <- matrix(1:100, 10, 10)
head(x)
head(x, n = -2)
tail(x)
left(x)
left(x, n = -2L)
right(x)
right(x, n = -2)
right(tail(x))

right(x, addcolnums = TRUE)
right(x, addcolnums = FALSE)

AEBilgrau/Bmisc documentation built on May 5, 2019, 11:28 a.m.