我尝试使用renderTable创建一个表,但它没有在浏览器上呈现。这是ss @ imgur
全桌code
这是renderTable代码:
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项目中仍然是新的,所以我不知道任何其他解决方案。我该怎么办,这个问题的原因是什么?谢谢!
(编辑)
答案 0 :(得分:0)
没有看到您使用的数据和ui,我们只能猜测。
使用来自diceR
的示例数据,我可以使用基础shiny
或DT
打印出表格。
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)