0
votes

I'm trying to make a table using renderTable but it's not rendering on the browser. Here's the ss @imgur

Full table's code

This's the renderTable 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 })

I've tried using

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

but it didn't work, as stated in here

I've also tried using renderUI, but instead it generate another error.

The table consist of number and string, but i think that's not the issue. Still new at this kind of R project, so I didn't know any other solution. What should I do, and what is the cause of this problem? Thanks!

(EDIT)

Sample data csv

ui.R

server.R

app.R

1
Please provide more code(in R, not HTML) with sample data - Pork Chop
I've added them, please evaluate, thanks. - psdm

1 Answers

0
votes

Without seeing the data that you use and the ui, we can only guess. Using the example data from diceR I am able to print out a table using base shiny or 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)