top_tail: First and last rows of a dataframe

View source: R/dataframe_tools.R

top_tailR Documentation

First and last rows of a dataframe

Description

First and last rows of a dataframe

Usage

top_tail(df, top = 3, tail = 3)

Arguments

df

(Dataframe) A dataframe.

top

(Integer) The number of rows to get from the start of df.

tail

(Integer) The number of rows to get from the end of df.

Details

0 can be provided for the top and tail, in which case it will behave like head() and tail() respectively.

Value

A dataframe.

Authors

Examples

# Returns 6 rows by default, just like head() does.
top_tail(iris)

#>     Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
#> 1            5.1         3.5          1.4         0.2    setosa
#> 2            4.9         3.0          1.4         0.2    setosa
#> 3            4.7         3.2          1.3         0.2    setosa
#> 148          6.5         3.0          5.2         2.0 virginica
#> 149          6.2         3.4          5.4         2.3 virginica
#> 150          5.9         3.0          5.1         1.8 virginica

top_tail(iris, top = 1, tail = 2)

#>     Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
#> 1            5.1         3.5          1.4         0.2    setosa
#> 149          6.2         3.4          5.4         2.3 virginica
#> 150          5.9         3.0          5.1         1.8 virginica


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.