Learn R Programming

photobiology (version 0.11.4)

head_tail: Return the First and Last Parts of an Object

Description

Returns the first and last "parts" (rows or members) of a spectrum, dataframe, vector, function, table or ftable. In other words, the combined output from methods head and tail.

Usage

head_tail(x, n, ...)

# S3 method for default head_tail(x, n = 3L, ...)

# S3 method for data.frame head_tail(x, n = 3L, ...)

# S3 method for matrix head_tail(x, n = 3L, ...)

# S3 method for `function` head_tail(x, n = 6L, ...)

# S3 method for table head_tail(x, n = 6L, ...)

# S3 method for ftable head_tail(x, n = 6L, ...)

Value

An object (usually) like x but smaller, except when

n = 0. For ftable objects x, a transformed

format(x).

Arguments

x

an R object.

n

integer. If positive, n rows or members in the returned object are copied from each of "head" and "tail" of x. If negative, all except n elements of x from each of "head" and "tail" are returned.

...

arguments to be passed to or from other methods.

Methods (by class)

  • head_tail(default):

  • head_tail(data.frame):

  • head_tail(matrix):

  • head_tail(`function`):

  • head_tail(table):

  • head_tail(ftable):

Details

The value returned by head_tail() is equivalent to row binding the the values returned by head() and tail(), although not implemented in this way. The same specializations as defined in package 'utils' for head() and tail() have been implemented.

See Also

head, and compare the examples and the values returned to the examples below.

Examples

Run this code

head_tail(1:20)
head_tail(1:20, 12)
head_tail(1:20, -7)
head_tail(1:20, -10)
head_tail(letters)
head_tail(sun.spct)
head_tail(sun.spct, 6)
head_tail(sun.data)
head_tail(as.matrix(sun.data))
head_tail(sun_evening.spct)
head_tail(sun_evening.mspct, 1L)

Run the code above in your browser using DataLab