Skip to contents

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.

Value

character.

Details

Inspired by the print method for DataFrame class.

Functions

  • headtail(data.frame): Same method as matrix.

  • headtail(list): Paste collapse to a character(1).

  • headtail(matrix): Show first and last rows.

Note

Updated 2023-09-20.

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"