使用转置后删除数据表中的标题

时间:2018-01-17 07:39:59

标签: r datatable shiny

我试图移除" V1"我的数据表中的标题是Shiny。

#Transpose DT
campaign_summary <- t(campaign_summary)

datatable(campaign_summary,
          colnames = NULL,
          options = list(dom = 't', bSort=FALSE),
          class = 'cell-border stripe')

这导致&#34;找不到匹配的记录&#34;。

使用renderDataTable在Shiny中显示数据表时,如何删除标题?

以下是campaign_summary的原始内容:

      Client Name   Min Date   Max Date Top Funnel Mid Funnel Misc Funnel Bot Funnel     Revenue
1      ABC        2016-05-02 2017-12-04      1,957        72  2         0        550          $0

以下是使用转置函数后campaign_summary的输出:

      [,1]          
Client Name "ABC"
Min Date    "2016-05-02"  
Max Date    "2017-12-04"  
Metric1     "1,957"       
Metric2     "722"         
Metric3     "0"           
Metric4     "550"         
Revenue     "$0"        

当前套餐:

  library(rstudioapi)
  library(lubridate)
  library(dplyr)
  library(RPostgreSQL)
  library(DBI)
  library(shiny)
  library(shinydashboard)
  library(scales)
  library(DT)

1 个答案:

答案 0 :(得分:2)

不确定为什么colnames = NULL无效,但您可以使用colnames = ""代替library(DT) library(tibble) df <- tibble( `Client Name` = "ABC", `Min Date` = "2016-05-02", `Max Date` = "2017-12-04" ) t_df <- t(df) DT::datatable( t_df, colnames = "", options = list(dom = "t", bSort = FALSE), class = "cell-border stripe" ) 。由于您无论如何都要禁用排序,这并不重要。

eureka:
  instance:
    instance-id: ${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${random.value}}

Result