Column Name Display

Hi,

I just signed up to the community and this is my first post! I'm trying to create my first shiny app as well. It seems that the users don't like seeing the default column names from a dataTable. Is there anyway I can only change the display name of the column and not the actual name (for referencing purposes)?

Thanks,

Eric

You can change the column names inside of the renderTable function and not affect the names outside of that function

library(shiny)
library(data.table)
library(shinydashboard)
library(ggplot2)

DT <- data.table(A = LETTERS[1:4], B = 11:14)
ui <- dashboardPage(
  dashboardHeader(title = "Test"),
  
  dashboardSidebar(
    
  ),
  
  dashboardBody(
    
    tableOutput("Tbl"),
    tableOutput("Tbl2"),
    plotOutput("Plt")
      )
)

server <- function(input, output, session) {
  output$Tbl <- renderTable({
    colnames(DT) <- c("NewA", "NewB")
    DT
  })
  output$Tbl2 <- renderTable({
    DT
  })
  output$Plt <- renderPlot({
    ggplot(DT, aes(A, B)) + geom_point()
  })
  
}

shinyApp(ui = ui, server = server)

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