Learn R Programming

ribiosUtils (version 1.7.7)

headtail: Print head and tail elements of a vector

Description

This function prints head and tail elements of a vector for visualization purposes. See examples for its usage.

Usage

headtail(vec, head = 2, tail = 1, collapse = ", ")

Value

A character string representing the vector

Arguments

vec

A vector of native types (e.g. character strings)

head

Integer, number of head elements to be printed

tail

Integer, number of tail elements to be printed

collapse

Character string, used to collapse elements

Author

Jitao David Zhang <jitao_david.zhang@roche.com>

Details

Head and tail elements are concatenated with ellipsis, if there are any elements that are not shown in the vector.

See Also

Examples

Run this code

testVec1 <- LETTERS[1:10]
headtail(testVec1)
headtail(testVec1, head=3, tail=3)
headtail(testVec1, head=3, tail=3, collapse="|")

testVec2 <- letters[1:3]
headtail(testVec2, head=1, tail=1)
headtail(testVec2, head=2, tail=1)

Run the code above in your browser using DataLab