pivot-shiny | R Documentation |
Display a pivot_table
in Shiny:
pivotOutput / renderPivot: adds a button to download pivot table in PowerPoint, Word and Excel.
pivot2Output / renderPivot2: display only the pivot table.
pivot2Output(outputId, width = "100%", ...)
renderPivot2(
expr,
width = 1,
background = "#81A1C1",
color = "#FFFFFF",
border = "#FFFFFF",
font_size = 14,
font_name = NULL,
labels = pivot_labels(),
formatter = pivot_formatter(),
env = parent.frame(),
quoted = FALSE
)
pivotOutput(outputId, width = "100%", export = export_labels(), ...)
export_labels(
export = "Export",
clipboard = "Copy to clipboard",
powerpoint = "Export to PowerPoint",
word = "Export to Word",
excel = "Export to Excel"
)
renderPivot(
expr,
width = 1,
background = "#81A1C1",
color = "#FFFFFF",
border = "#FFFFFF",
font_size = 11,
font_name = NULL,
labels = pivot_labels(),
formatter = pivot_formatter(),
label_value = "value",
env = parent.frame(),
quoted = FALSE,
filename = "export-pivot"
)
outputId |
Output variable to read from. |
width |
Value of the preferred width of the table in percent ( |
... |
Other arguments to pass to the container tag function. This is useful for providing additional classes for the tag. |
expr |
An expression that generates a |
background |
Background color for the header and column(s) containing row(s). |
color |
Text color for the header and column(s) containing row(s). |
border |
Border color (applies to all table). |
font_size |
Font size (applies to all table). |
font_name |
Font name (applies to all table). |
labels |
Custom labels for statistics, see |
formatter |
Function to format content, see |
env |
The environment in which to evaluate |
quoted |
Is |
export |
Export labels, use |
clipboard, powerpoint, word, excel |
Labels to display in
export menu, use |
label_value |
For Excel output, the label for variable containing the values. |
filename |
A string of the filename to export WITHOUT extension, it will be added accordint to type of export. |
An HTML output element that can be included in Shiny UI.
library(shiny)
library(flexpivot)
data("nobel_laureates")
ui <- fluidPage(
tags$h2("Pivot table in Shiny"),
fluidRow(
column(
width = 6,
selectInput(
inputId = "row",
label = "Row",
choices = c("category", "gender", "birth_continent", "laureate_type"),
width = "100%"
)
),
column(
width = 6,
selectInput(
inputId = "col",
label = "Col",
choices = c("category", "gender", "birth_continent", "laureate_type"),
selected = "gender",
width = "100%"
)
)
),
pivotOutput("pivot")
)
server <- function(input, output, session) {
output$pivot <- renderPivot({
pivot_table(nobel_laureates, input$row, input$col)
}, background = "#A3BE8C")
}
if (interactive())
shinyApp(ui, server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.