source("isDeGene.R")
shinyServer( function(input, output) {
output$geneDe <- renderTable({ isDeGene(input$geneSymbol) })})
source("isDeGene.R")
shinyServer( function(input, output) {
df = isDeGene(input$geneSymbol)
output$geneDe <- renderTable({ df })
output$nbGeneDe <- renderText({ paste("Data frame length : ",length(df)) })
})Hi everyone,I'm using the functions renderTable and tableOutput to display a data frame that changes depending on the input parameter.source("isDeGene.R")shinyServer(function(input, output) {output$geneDe <- renderTable({isDeGene(input$geneSymbol)})})It may happen that the data frame is empty. In this case, I would like to display some message. I can't see how I can do that with Shiny (I'm very new to it).
The second question is kind of related with the first one.I would like to display both my data frame and its length. Somehow I would like to do something like that :source("isDeGene.R")shinyServer(function(input, output) {df = isDeGene(input$geneSymbol)output$geneDe <- renderTable({df})output$nbGeneDe <- renderText({paste("Data frame length : ",length(df))})})But I'm getting the following error message :Error in .getReactiveEnvironment()$currentContext() :Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
Hi
On Wednesday, October 22, 2014 12:21:13 PM UTC+2, Ed wrote:Hi everyone,I'm using the functions renderTable and tableOutput to display a data frame that changes depending on the input parameter.source("isDeGene.R")shinyServer(function(input, output) {output$geneDe <- renderTable({isDeGene(input$geneSymbol)})})It may happen that the data frame is empty. In this case, I would like to display some message. I can't see how I can do that with Shiny (I'm very new to it).A solution is quite simple: wrap your isDeGene() function inside an if environment, returning something only if your data frame has at least one row. Similarly, you can add a renderText, producing a message when your data is empty.
The second question is kind of related with the first one.I would like to display both my data frame and its length. Somehow I would like to do something like that :source("isDeGene.R")shinyServer(function(input, output) {df = isDeGene(input$geneSymbol)output$geneDe <- renderTable({df})output$nbGeneDe <- renderText({paste("Data frame length : ",length(df))})})But I'm getting the following error message :Error in .getReactiveEnvironment()$currentContext() :Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)df depends from an input value, so it must be defined in a reactive expression, as the message says.Try replacing df = isDeGene(input$geneSymbol with df <- reactive({isDeGene(input$geneSymbol)})