Skip to contents

Print the first and last rows of a data frame using head and tail, respectively. Print the number of omitted rows

Usage

headtail(x, n = 6, pattern = "[%d rows omitted]")

Arguments

x

data frame

n

total number of rows to be printed.

pattern

pattern given to sprintf containing a %d placeholder to print the number of omitted rows

Value

number of omitted rows, invisibly

Examples

x <- data.frame(number = 1:26, letter = LETTERS)
headtail(x)
#>   number letter
#> 1      1      A
#> 2      2      B
#> 3      3      C
#> [20 rows omitted] 
#>    number letter
#> 24     24      X
#> 25     25      Y
#> 26     26      Z
headtail(x, 10)
#>   number letter
#> 1      1      A
#> 2      2      B
#> 3      3      C
#> 4      4      D
#> 5      5      E
#> [16 rows omitted] 
#>    number letter
#> 22     22      V
#> 23     23      W
#> 24     24      X
#> 25     25      Y
#> 26     26      Z
headtail(x, 16)
#>   number letter
#> 1      1      A
#> 2      2      B
#> 3      3      C
#> 4      4      D
#> 5      5      E
#> 6      6      F
#> 7      7      G
#> 8      8      H
#> [10 rows omitted] 
#>    number letter
#> 19     19      S
#> 20     20      T
#> 21     21      U
#> 22     22      V
#> 23     23      W
#> 24     24      X
#> 25     25      Y
#> 26     26      Z
headtail(x[10:20, ], 10)
#>    number letter
#> 10     10      J
#> 11     11      K
#> 12     12      L
#> 13     13      M
#> 14     14      N
#> [1 rows omitted] 
#>    number letter
#> 16     16      P
#> 17     17      Q
#> 18     18      R
#> 19     19      S
#> 20     20      T