更改Shiny数据表中的列名

时间:2019-04-22 17:50:53

标签: r shiny

我正在尝试更改闪亮的数据表的列标题。到目前为止,这是我所做的。我在服务器部分的代码中添加了注释。我正在尝试更改列名并将行的选择限制为单个。

 addr <- as.data.table(read.csv("addresses.csv", header = T, stringsAsFactors = F)

ui <- fluidPage(
  br(),
  fluidRow(
    column(12, div(DT::dataTableOutput("addressTable"), style="font-family:verdana", align="left"))
  ),
  fluidRow(
    column(4, div(textOutput("selectedAddress"), align="center"))
  )
)

server <- function(input, output) {
      # output$addressTable <- DT::renderDataTable({
      #   names(addr) [1:4]<- c("STREET ADDRESS","CITY NAME","PROVINCE","POSTAL CODE")
      #   addr
      # }) -- This code works, I was able to change the column headers but not able to add the selection single option.

      output$addressTable <- DT::renderDataTable(addr, selection = 'single') - this code works with the selection to single, but not able to change column headers.

}    
shinyApp(ui, server)

0 个答案:

没有答案