Your two questions are very different. I reply to the second one. Please open another question for the first one.
The solution I propose makes use of the jQuery plugin freeze Table.
library(shiny)
widetbl <- t(iris[1:40,]) # a wide table for the illustration
js <- HTML(paste0(c(
'$(document).on("shiny:value", function(evt) {',
' if(evt.name === "wideTable") {',
' setTimeout(function() {',
' $("#wideTable").freezeTable({',
' fastMode: true,',
' columnNum: 2',
' });',
' }, 0);',
' }',
'});'
), collapse = "\n"))
ui <- fluidPage(
tags$head(
tags$script(
src = "https://cdn.jsdelivr.net/gh/yidas/jquery-freeze-table/dist/js/freeze-table.min.js"
),
tags$script(js)
),
br(),
tableOutput("wideTable")
)
server <- function(input, output, session){
output[["wideTable"]] <- renderTable({
widetbl
})
}
shinyApp(ui, server)
CLICK HERE to find out more related problems solutions.