I found an interesting package rpivotTable
. I would like to create shiny app
one that includes rpivotTable
the ability to load generated data using downloadHandler
.
However, I cannot find a solution, how to create data.frame
or something else that I could pass to the function downloadHandler
.
rpivotTable
creates an object of class:
class(pivot)
[1] "rpivotTable" "htmlwidget"
Are there any options for loading the output of this function?
In addition, I am attaching an example of how a bar is created in a brilliant state and an example of a load function that I would like to use.
Perhaps there are other ideas or suggestions?
set.seed(1992)
n=99
Year <- sample(2013:2015, n, replace = TRUE, prob = NULL)
Month <- sample(1:12, n, replace = TRUE, prob = NULL)
Category <- sample(c("Car", "Bus", "Bike"), n, replace = TRUE, prob = NULL)
Brand <- sample("Brand", n, replace = TRUE, prob = NULL)
Brand <- paste0(Brand, sample(1:14, n, replace = TRUE, prob = NULL))
USD <- abs(rnorm(n))*100
df <- data.frame(Year, Month, Category, Brand, USD)
output$Pivot <- rpivotTable::renderRpivotTable({
rpivotTable(data = df, rows = "Brand", col = "Category", vals = "USD", aggregatorName = "Sum", rendererName = "Table")
})
output$downloadData <- downloadHandler(
filename = function() { paste(filename, '.csv', sep='') },
content = function(file) {
write.csv(PivotOutput, file)
})