I'm running some code where I'm trying to render a dataframe in a Shiny App. When I test the code locally without using a dynamic input filter the table is created ok, but when I run it in Shiny I get the following error. I don't see how this wouldn't be a dataframe.
Warning: Error in datatable: 'data' must be 2-dimensional (e.g. data frame or matrix)
[No stack trace available]
A summary of the code is
server <- function(input, output) {
# Outputs for totals
output$Total_tableAll <- DT::renderDataTable({
...
Total_table<-Total_PremLoss %>%
group_by(CY)%>%
dplyr::summarise('Booked Premium'=sum(Booked_Prem),
'Earned Premium' = sum(EP),
Commission=sum(Commission)/sum(EP),
Incurred=sum(Incurred),
ILR = sum(Incurred)/sum(EP),
'NonCAT ILR' = sum(nonCATLoss)/sum(EP),
'CAT ILR' = sum(CATLoss)/sum(EP),
'Comm ILR'= Commission+ILR)
DT::datatable(data = Total_table,
container=cont_total,
rownames = FALSE,
caption = 'All LOB',
option=list(dom='t'
))%>%
formatCurrency(
c('Booked Premium', 'Earned Premium', 'Incurred'),
currency="$",digits=0)%>%
formatPercentage(
c('ILR', 'NonCAT ILR', 'CAT ILR', 'Comm ILR', 'Commission'))
)}