Unfortunately I can't use my actual data.frame since it is not mine and is copyrighted, but I will try to explain as best as I can
I have a data.frame that contains a column with unique strings. when I do datatable(mydf) in the Rstudio console, it shows me the correct table in viewer. However, when I do the same in shiny I get this warning:
Warning in [<-.data.frame
(*tmp*
, , j, value = list("ECDTM-12 Trimmed eTAG truncated after Fn F232C No Stop CRLF2 transcript variant 1 NM_022148_3", :
provided 10 variables to replace 1 variables
essentially what it does is it takes the first string in that column "ECDTM-12 Trimmed eTAG truncated after Fn F232C No Stop CRLF2 transcript variant 1 NM_022148_3" and overrides every other string in that row with this string, instead of showing what those rows actually contain
some maybe helpful code:
library(shiny)
library(shinythemes)
library(shinycssloaders)
library(dplyr)
library(readr)
library(xlsx)
library(openxlsx)
library(ggplot2)
library(reshape2)
library(ggthemes)
library(DT)
set.seed(1)
code in the UI function:
fluidRow(column(12, align="center", withSpinner(dataTableOutput("partTables")
code in the server function:
Lib_P1_P2 <- reactive(if(LibName() == "1.1A" | LibName() == "1.1B" | LibName() == "2.1"){readRDS(paste0("data/",input$library," P1_P2.rds"))})
output$partTables <- renderDataTable({
datatable(Lib_P1_P2(),options=list(pagelength=10), rownames = FALSE, escape = FALSE)
})
I added set.seed(1) and escape=FALSE after I saw this question: R Shiny renderDataTable issue but that didn't work either..
If I've left out any important info, let me know I'd be happy to provide. I'm new to stackoverflow so excuse my newbie-ness.
renderDataTable()
return your data.frame directly, rather than passing it throughDatatable
first. The shiny example of integrating with data tables does this. – Artem SokolovrenderDataTable
withDT::renderDataTable
anddataTableOutput
withDT::dataTableOutput
to make sure the correct namespace is used. These functions also exist in theshiny
package – Gregor de CilliaDT::renderDataTable({datatable(...)})
should give you almost the same table as in the RStudio console. – Gregor de Cillia