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.
Functions
headtail(data.frame)
: Same method asmatrix
.headtail(list)
: Paste collapse to acharacter(1)
.headtail(matrix)
: Show first and last rows.
Examples
data(mtcars, package = "datasets")
## atomic ====
headtail(LETTERS)
#> [1] "A B ... Y Z"
## data.frame ====
headtail(mtcars)
#> [1] " mpg cyl ... gear carb"
#> [2] "Mazda RX4 21 6 ... 4 4"
#> [3] "Mazda RX4 Wag 21 6 ... 4 4"
#> [4] "... ... ... ... ... ..."
#> [5] "Maserati Bora 15 8 ... 5 8"
#> [6] "Volvo 142E 21.4 4 ... 4 2"