0

I want to export the pivot table data as shown in the image in csv, excel, pdf form using buttons (Note: I don't want to export the actual data). However i'm unable to do so, can't figure out the reason due to my limited knowledge. Please guide me, I shall be really thankful for the help.

Kind regards

need to save this out put data

My code :

library(rpivotTable)
library(dplyr)
library(readr)
library(shiny)

#ui
ui = fluidPage(
radioButtons(inputId="format", label="Enter the format to download", 
choices=c("none", "csv", "excel", "pdf", "copy"), selected="none"),

fluidRow( rpivotTableOutput("pivot")))


#server
server = function(input, output) { 


output$pivot <- renderRpivotTable( rpivotTable::rpivotTable( rows = c( 
"vs"),cols=c("carb"),vals =  "mpg", aggregatorName = "Sum",rendererName =  
"Table",width="50%", height="550px",
{
data <- mtcars

if(input$format =="csv") {
write_csv( data, 'data.csv')

} 
if (input$format=="excel") {
write.xlsx(data, "data.xlsx")
} 

data
}))}

shinyApp(ui = ui, server = server)
Sid
  • 53
  • 8

0 Answers0