【问题标题】:R shiny table not renderingR闪亮的桌子不渲染
【发布时间】:2018-06-19 04:58:03
【问题描述】:

我正在尝试使用 renderTable 制作表格,但它没有在浏览器上呈现。这里是ss @imgur

全桌code

这是渲染表代码:

library(shiny)
library(diceR)

output$clustensemble <- renderTable({
#load file
data <- data()

#consensus cluster
cc <- consensus_cluster(data, nk=3, reps=1, algorithms=c("km","hc"), progress=FALSE)
ce <- as.matrix(cc)
tce <- t(ce)
tce })

我尝试过使用

sanitize.text.function = function(x) x;

但它不起作用,如here中所述

我也尝试过使用 renderUI,但它会产生另一个错误。

表格由数字和字符串组成,但我认为这不是问题。 在这种 R 项目中仍然是新手,所以我不知道任何其他解决方案。我该怎么办,这个问题的原因是什么?谢谢!

(编辑)

Sample data csv

ui.R

server.R

app.R

【问题讨论】:

  • 请提供更多代码(R,而不是 HTML)和示例数据
  • 已添加,请评价,谢谢。

标签: r shiny


【解决方案1】:

没有看到你使用的数据和用户界面,我们只能猜测。 使用来自diceR 的示例数据,我可以使用基础shinyDT 打印出一个表格。

library(shiny)
library(DT)
library(diceR)

data(hgsc)
# Custom distance function
manh <- function(x) {
  stats::dist(x, method = "manhattan")
}
# Custom clustering algorithm
agnes <- function(d, k) {
  return(as.integer(stats::cutree(cluster::agnes(d, diss = TRUE), k)))
}
assign("agnes", agnes, 1)

ui <- fluidPage(
  DT::dataTableOutput("tableDT"),
  tableOutput("table")
)

server <- function(input, output){

  data <- reactive({
    dat <- hgsc[1:10, 1:50]
    cc <- consensus_cluster(dat, reps = 6, algorithms = c("pam", "agnes"),
                            distance = c("euclidean", "manh"), progress = FALSE)
    ce <- as.matrix(cc)
    t(ce)
  })

  output$tableDT <- DT::renderDataTable({
    data()
  })

  output$table <- renderTable({
    data()
  })
}

shinyApp(ui, server)

【讨论】:

  • 我已经编辑了我的帖子,拜托。我会在此期间尝试您的解决方案
  • 不行,好像是数据问题。它伴随着这个错误Warning in stats::dist(x = x, method = dist) : NAs introduced by coercion
  • 你在clustensemble 的用户界面中没有tableOutput 还是我看错了?我看到的只是一个verbatimTextOutput,这是一个错误的表格方法..
猜你喜欢
  • 2021-06-19
  • 2015-01-11
  • 2016-12-15
  • 2021-06-17
  • 2021-04-19
  • 1970-01-01
  • 2018-01-25
  • 2015-10-19
  • 2016-06-12
相关资源
最近更新 更多