error displaying loss triangles in shiny app
error displaying loss triangles in shiny app

Ok so I'm building an app and literally just trying to show loss triangles by whatever line of business selected. I have a function to create the triangles (using the chainladder package) which outputs a matrix. I set some global options & then I render the data table. I swear this worked for me a couple weeks ago... I was getting pretty triangles with commas & everything. Now the commas dont work anymore and I can't even get the triangles to show up at all. I keep getting an error that says "no matching records found" but it says at the bottom showing 0 to 0 of 0 entries (filtered from 121 total). I thought my problem had to do with the smart filtering so I turned that off, but still nothing. Please help!!
triangles <- function(filt_dat, tri_type, cum_inc) {
# creating the triangles... either cumulative or incremental
if(cum_inc == "cum"){
triangles <-
as.triangle(filt_dat, origin = "AY", dev = "AY_age", value = tri_type) %>%
round(., digits = 0)
} else {
triangles <-
as.triangle(filt_dat, origin = "AY", dev = "AY_age", value = tri_type) %>%
cum2incr(.) %>%
round(., digits = 0)
}
return(triangles)
}
#___________________________________________________________________________________
# global option for all data tables
options(
DT.options =
list(
dom = 'Bt', #only display table & buttons... nothing else
columnDefs = list(list(width = '100px')),
scrollX = T, #allow it scroll right when large # of cols
ordering = F,
paging = F,
search = list(smart = F),
# pageLength = 20,
initComplete = DT::JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'background-color': '#7a8b8b', 'color': '#fff'});",
"}"
)
)
)
#___________________________________________________________________________________
output$Tri1 <- DT::renderDataTable({
show_tri <- triangles(tri_dat(), "new_loss_incd", input$cum_inc)
# show_tri <- comma(show_tri, 0) %>% gsub("NA", replacement = "", x = .)
show_tri
# }
},
# server = F, # this shows it as a datatable (not triangle)... comment it out tho & no matching records found
extensions = c('Buttons'),
selection = 'none',
options = list(buttons = list('copy',
'print',
list(extend = 'collection',
buttons = c('excel','pdf'),
text = 'Download')
)
)
)
Answers
Sounds like maybe there are two issues:
In either case it would be hard to troubleshoot just by looking at the above code. Can you post a link to your page or a test case showing the issues?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin