Return the first and last parts of an object
Source:R/AllGenerics.R
, R/headtail-methods.R
headtail.Rd
Applies to both rows and columns, enabling quick inspection during interactive use.
Usage
headtail(x, ...)
# S4 method for data.frame
headtail(x, n = 2L)
# S4 method for list
headtail(x, n = 2L)
# S4 method for matrix
headtail(x, n = 2L)
# S4 method for vector
headtail(x, n = 2L)
Arguments
- x
Object.
- n
integer(1)
. Positive integer denoting the number of first and last items to include.- ...
Additional arguments.
Details
Inspired by the print()
method for DataFrame
class
objects.
Functions
headtail,data.frame-method
: Same method asmatrix
.headtail,list-method
: Paste collapse to acharacter(1)
.headtail,matrix-method
: Show first and last rows.
Examples
data(mtcars, package = "datasets")
## data.frame ====
headtail(mtcars)
#> mpg cyl ... gear carb
#> Mazda RX4 21 6 ... 4 4
#> Mazda RX4 Wag 21 6 ... 4 4
#> ... ... ... ... ... ...
#> Maserati Bora 15 8 ... 5 8
#> Volvo 142E 21.4 4 ... 4 2