repeat.nth: Hide repetition of character strings

View source: R/repeath.nth.r

repeat.nthR Documentation

Hide repetition of character strings

Description

Creates a vector in which text is repeated every "nth" item in the result, and in which that text is concatenated with a numeric integer indicating which occurence it represents. Useful for making good-looking, not-too busy Appendix tables of for example observed concentrations with multiple samples taken at various dose levels and/or various dosing cycles.

Usage

repeat.nth(x, replacement = "", before = "", after = "", pos = 1)

Arguments

x

numeric or character

replacement

character string to replace the repeated entries (defaults to the empty "")

before

prefix (optional)

after

suffix (optional)

pos

position within the repetition the non-empty character string should appear

Value

Character vector

Examples

## simplest form
repeat.nth(c(1,1,1,1,2,2,2))

## adding a prefix
repeat.nth(c(1,1,1,1,2,2,2), before = "CYCLE", pos = 1)
repeat.nth(c(1,1,1,1,2,2,2), before = "CYCLE", pos = 2)
repeat.nth(c(1,1,1,1,2,2,2), before = "CYCLE", pos = 3)

## addding a suffix
repeat.nth(c(1,1,1,1,2,2,2), after = "CYCLE", pos = 1)
repeat.nth(c(1,1,1,1,2,2,2), after = "CYCLE", pos = 2)
repeat.nth(c(1,1,1,1,2,2,2), after = "CYCLE", pos = 3)

## both
repeat.nth(c(1,1,1,1,2,2,2), before = "BI", after = "CYCLE", pos = 1)

qPharmetra/qpToolkit documentation built on May 24, 2023, 8:52 a.m.