View source: R/interactiveTable.R
interactiveTable | R Documentation |
This function wraps the htmlTable and adds JavaScript code for toggling the amount of text shown in any particular cell.
interactiveTable(
x,
...,
txt.maxlen = 20,
button = getOption("htmlTable.interactiveTable.button", default = FALSE),
minimized.columns = NULL,
js.scripts = c()
)
## S3 method for class 'htmlTable'
interactiveTable(
x,
...,
txt.maxlen = 20,
button = getOption("htmlTable.interactiveTable.button", default = FALSE),
minimized.columns = NULL,
js.scripts = c()
)
## S3 method for class 'interactiveTable'
knit_print(x, ...)
## S3 method for class 'interactiveTable'
print(x, useViewer, ...)
x |
The table to be printed |
... |
The exact same parameters as |
txt.maxlen |
The maximum length of a text |
button |
Indicator if the cell should be clickable or if a button should appear with a plus/minus |
minimized.columns |
Notifies if any particular columns should be collapsed from start |
js.scripts |
If you want to add your own JavaScript code you can just add it here.
All code is merged into one string where each section is wrapped in it's own
|
useViewer |
If you are using RStudio there is a viewer thar can render
the table within that is envoced if in |
An htmlTable with a javascript attribute containing the code that is then printed
library(magrittr)
# A simple output
long_txt <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum"
short_txt <- gsub("(^[^.]+).*", "\\1", long_txt)
cbind(rep(short_txt, 2),
rep(long_txt, 2)) %>%
addHtmlTableStyle(col.rgroup = c("#FFF", "#EEF")) %>%
interactiveTable(minimized.columns = ncol(.),
header = c("Short", "Long"),
rnames = c("First", "Second"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.