addLineBreak: Break lines in a text column of a dataframe.

Description Usage Arguments Value Author(s) Examples

View source: R/addLineBreak.r

Description

Given a dataframe with a column containing character string, generate a new dataframe where these strings have a maximal length. Useful when embedding dataframes in a Sweave document, without having it overlapping page width.

Usage

1

Arguments

tab

Dataframe containing the data.

length

Maximal length to which strings should be broken.

col

Column of tab that contains strings.

Value

List with two elements: The resulting dataframe with lines broken, and a vector that gives row where each entry in the new dataframe ends. The latter is useful when horizontal lines should be added when using xtable.

Author(s)

Kaspar Rufibach (maintainer), kaspar.rufibach@gmail.com,
http://www.kasparrufibach.ch

Examples

1
2
3
4
5
6
7
8
tab <- data.frame(cbind(1:4))
tab[1, 2] <- paste(letters, sep = "", collapse = "")
tab[3, 2] <- paste(LETTERS, sep = "", collapse = "")
tab[c(2, 4), 2] <- ""
colnames(tab) <- c("nr", "text")

tab
addLineBreak(tab, length = 12, col = 2)

reporttools documentation built on Oct. 12, 2021, 5:06 p.m.