head_tail: *!!* Show several first and last rows of a data frame

Description Usage Arguments Value Examples

View source: R/head_tail.R

Description

This function selects several top and bottom rows of a data frame for a preview.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
head_tail(
  obj,
  n = 4,
  format = c("f", "g", "e"),
  sep = "...",
  max_decimals = NULL,
  signif_digits = 3,
  tolerance = 2,
  top = n,
  bottom = n
)

Arguments

obj

A data frame.

n

(integer) Number of top and bottom rows to display.

format

equal to "d" (for integers), "f", "e", "E", "g", "G", "fg" (for reals), or "s" (for strings). Default is "d" for integers, "g" for reals.

"f" gives numbers in the usual xxx.xxx format; "e" and "E" give n.ddde+nn or n.dddE+nn (scientific format); "g" and "G" put x[i] into scientific format only if it saves space to do so and drop trailing zeros and decimal point - unless flag contains "#" which keeps trailing zeros for the "g", "G" formats.

"fg" (our own hybrid format) uses fixed format as "f", but digits as the minimum number of significant digits. This can lead to quite long result strings, see examples below. Note that unlike signif this prints large numbers with more significant digits than digits. Trailing zeros are dropped in this format, unless flag contains "#".

sep

(character) Separator between displayed top and bottom lines.

max_decimals

(integer, NULL) Maximum number of decimal digits to bpint. If NULL, no restrictions applied.

signif_digits

(integer, NULL) Number of significant digits used to determine appropriate rounding. If NULL, all digits are used to determine the appropriate rounding.

tolerance

(integer) For small datasets, number of rows to show in addition to top and bottom before the dataset is truncated.

top

(integer) Number of top rows to display.

bottom

(integer) Number of bottom rows to display.

Value

A truncated data frame (which is intended to be printed) with all variables converted to strings.

Examples

1
2
3
4
5
6
7
8
9
library(biostat)

data(swiss)
head_tail(swiss)

data(swiss)
head_tail(iris, n = 2)
head_tail(iris[1:6, ], n = 2, tolerance = 1)
head_tail(iris[1:6, ], n = 2, tolerance = 2)

GegznaV/BioStat documentation built on Aug. 14, 2020, 9:30 p.m.