repeat.nth | R Documentation |
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.
repeat.nth(x, replacement = "", before = "", after = "", pos = 1)
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 |
Character vector
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.