我试图使用renderTable创建一个表,但它不是在浏览器上呈现的。这是ss @印古尔
全表的代码
这是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 =函数(X) x;
但它没有起作用,正如这里中所说的
我也尝试过使用renderUI,但是相反,它会产生另一个错误。
该表由数字和字符串组成,但我认为这不是问题所在。在这种R项目中还是新的,所以我不知道任何其他的解决方案。我应该做什么,造成这个问题的原因是什么?谢谢!
(编辑)
发布于 2018-06-19 12:20:10
没有看到您使用的数据和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)https://stackoverflow.com/questions/50920906
复制相似问题