How to extend width of KableExtra tableoutput

Hello,

I want to increase size of KableExtra table in shiny app. I have wright following code:

kbltbl <- function(a, Segment, is_init_sec,IS_SECURED){
    a %>% kbl(caption = paste("Default poolling for ", Segment, ": triggered by",
                              ifelse(is_init_sec==0,"unsecured", "secured"), "portfolio, ", 
                              ifelse(IS_SECURED==F, "unsecured", "secured"), " pooling (exposure-based)")) %>%
        kable_classic(full_width = T, html_font = "Cambria")%>%
        row_spec(which(a$STAGEE=="2"), background = "#FAF421", bold = T, color = "black")%>%
        row_spec(which(a$STAGEE=="3"), background = "#EE6600", bold = T, color = "black")%>%
        row_spec(which(a$STAGEE=="1"), background = "#55D0A9", bold = T, color = "black")
}
    
get_dt <-function(df, Segment, is_init_sec,IS_SECURED){
    df %>%filter(LOAN_SEGMENT == Segment & is_init_sec==is_init_sec & IS_SECURED==IS_SECURED ) %>%
        filter(!(GCA_LCY<=0 & IS_WRITE_OFF == F)) %>%
        group_by( `Months after default`, STAGEE) %>%
        summarise(sum_GCA = sum(GCA_LCY, na.rm = T)) %>%
        pivot_wider(names_from = `Months after default`, values_from = sum_GCA)%>%
        mutate(STAGEE=factor(STAGEE))%>%
        modify_if(is.numeric, ~coalesce(.,0))%>%
        modify_if(is.numeric,prop.table)%>%
        modify_if( is.numeric, round,digits = 4)%>%
        modify_if(is.numeric, percent)  
} 

# Define UI for application that draws a histogram
ui <- fluidPage(

    # Application title
    titlePanel("TBC pooling"),

    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            sliderInput('threshold', 'Threshold', min=.1, max=.5,
                                 value=.2, step=.1, round=2),
                     
                     checkboxInput('Pawn', 'Pawn Loans', value = TRUE),
                     checkboxInput('Auto', 'Auto', value = TRUE),
                     
                     selectInput('Segment', 'Segment', unique(df_def$LOAN_SEGMENT)),
                     selectInput('IS_SECURED', 'Is Secured', unique(df_def$IS_SECURED)),
                     selectInput('is_init_sec', 'Is initial secured', unique(df_def$is_init_sec))
                     
        ),

        # Show a plot of the generated distribution
        mainPanel(
            tableOutput("poolingtbl") 
                    )
    )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

    a<- reactive({
            get_dt(df_def, input$Segment, input$is_init_sec, input$IS_SECURED)
        })
    
         
    output$poolingtbl <- function()(kbltbl(a(), input$Segment, input$is_init_sec, input$IS_SECURED))
}        


# Run the application 
shinyApp(ui = ui, server = server)

and I get following result:

how can I increase size of this table?

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.