Skip to contents
  • print_headtail() - Print the head and tail rows of the data.

  • print_interval() - Print the selected rows with (almost) equal intervals.

  • slice_headtail() - Return the head and tail rows of the data.

  • slice_interval() - Return the selected rows with (almost) equal intervals.

Usage

print_headtail(
  .data,
  n = 10,
  width = NULL,
  ...,
  max_extra_cols = NULL,
  max_footer_lines = NULL
)

print_interval(
  .data,
  n = 10,
  width = NULL,
  ...,
  max_extra_cols = NULL,
  max_footer_lines = NULL
)

slice_headtail(.data, n = 10)

slice_interval(.data, n = 10)

Arguments

.data

A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

n

A positive integer. The number of rows to show in the head and in the tail.

width

A positive integer. The width of the printed tibble.

...

Passed on to tbl_format_setup().

max_extra_cols

Number of extra columns to print abbreviated information for, if the width is too small for the entire tibble. If NULL, the max_extra_cols option is used. The previously defined n_extra argument is soft-deprecated.

max_footer_lines

Maximum number of footer lines. If NULL, the max_footer_lines option is used.

Value

Print the selected rows of the data. Return the input data frame invisibly.

Examples

print_headtail(starwars)
#> # A tibble: 87 × 14
#>    name     height  mass hair_color skin_color eye_color birth_year sex   gender
#>    <chr>     <int> <dbl> <chr>      <chr>      <chr>          <dbl> <chr> <chr> 
#>  1 Luke Sk…    172    77 blond      fair       blue            19   male  mascu…
#>  2 C-3PO       167    75 NA         gold       yellow         112   none  mascu…
#>  3 R2-D2        96    32 NA         white, bl… red             33   none  mascu…
#>  4 Darth V…    202   136 none       white      yellow          41.9 male  mascu…
#>  5 Leia Or…    150    49 brown      light      brown           19   fema… femin…
#> 83 Rey          NA    NA brown      light      hazel           NA   fema… femin…
#> 84 Poe Dam…     NA    NA brown      light      brown           NA   male  mascu…
#> 85 BB8          NA    NA none       none       black           NA   none  mascu…
#> 86 Captain…     NA    NA unknown    unknown    unknown         NA   NA    NA    
#> 87 Padmé A…    165    45 brown      light      brown           46   fema… femin…
#> # ℹ 77 more rows in the middle
#> # ℹ 5 more variables: homeworld <chr>, species <chr>, films <list>,
#> #   vehicles <list>, starships <list>
#> # ℹ Use `print_headtail(n = ...)` to see more rows

print_interval(starwars)
#> # A tibble: 87 × 14
#>    name     height  mass hair_color skin_color eye_color birth_year sex   gender
#>    <chr>     <int> <dbl> <chr>      <chr>      <chr>          <dbl> <chr> <chr> 
#>  1 Luke Sk…    172    77 blond      fair       blue            19   male  mascu…
#> 11 Anakin …    188    84 blond      fair       blue            41.9 male  mascu…
#> 20 Palpati…    170    75 grey       pale       yellow          82   male  mascu…
#> 30 Nien Nu…    160    68 none       grey       black           NA   male  mascu…
#> 39 Sebulba     112    40 none       grey, red  orange          NA   male  mascu…
#> 49 Ki-Adi-…    198    82 white      pale       yellow          92   male  mascu…
#> 58 Cordé       157    NA brown      light      brown           NA   fema… femin…
#> 68 Dexter …    198   102 none       brown      yellow          NA   male  mascu…
#> 77 Grievous    216   159 none       brown, wh… green, y…       NA   male  mascu…
#> 87 Padmé A…    165    45 brown      light      brown           46   fema… femin…
#> # ℹ 77 more rows between the intervals
#> # ℹ 5 more variables: homeworld <chr>, species <chr>, films <list>,
#> #   vehicles <list>, starships <list>
#> # ℹ Use `print_interval(n = ...)` to see more rows

slice_headtail(starwars)
#> # A tibble: 10 × 14
#>    name     height  mass hair_color skin_color eye_color birth_year sex   gender
#>    <chr>     <int> <dbl> <chr>      <chr>      <chr>          <dbl> <chr> <chr> 
#>  1 Luke Sk…    172    77 blond      fair       blue            19   male  mascu…
#>  2 C-3PO       167    75 NA         gold       yellow         112   none  mascu…
#>  3 R2-D2        96    32 NA         white, bl… red             33   none  mascu…
#>  4 Darth V…    202   136 none       white      yellow          41.9 male  mascu…
#>  5 Leia Or…    150    49 brown      light      brown           19   fema… femin…
#>  6 Rey          NA    NA brown      light      hazel           NA   fema… femin…
#>  7 Poe Dam…     NA    NA brown      light      brown           NA   male  mascu…
#>  8 BB8          NA    NA none       none       black           NA   none  mascu…
#>  9 Captain…     NA    NA unknown    unknown    unknown         NA   NA    NA    
#> 10 Padmé A…    165    45 brown      light      brown           46   fema… femin…
#> # ℹ 5 more variables: homeworld <chr>, species <chr>, films <list>,
#> #   vehicles <list>, starships <list>

slice_interval(starwars)
#> # A tibble: 10 × 14
#>    name     height  mass hair_color skin_color eye_color birth_year sex   gender
#>    <chr>     <int> <dbl> <chr>      <chr>      <chr>          <dbl> <chr> <chr> 
#>  1 Luke Sk…    172    77 blond      fair       blue            19   male  mascu…
#>  2 Anakin …    188    84 blond      fair       blue            41.9 male  mascu…
#>  3 Palpati…    170    75 grey       pale       yellow          82   male  mascu…
#>  4 Nien Nu…    160    68 none       grey       black           NA   male  mascu…
#>  5 Sebulba     112    40 none       grey, red  orange          NA   male  mascu…
#>  6 Ki-Adi-…    198    82 white      pale       yellow          92   male  mascu…
#>  7 Cordé       157    NA brown      light      brown           NA   fema… femin…
#>  8 Dexter …    198   102 none       brown      yellow          NA   male  mascu…
#>  9 Grievous    216   159 none       brown, wh… green, y…       NA   male  mascu…
#> 10 Padmé A…    165    45 brown      light      brown           46   fema… femin…
#> # ℹ 5 more variables: homeworld <chr>, species <chr>, films <list>,
#> #   vehicles <list>, starships <list>