renderPrint in interactive shiny document does not work properly

Hi, using this document below works locally, but not on a shiny server. Instead of the contents of x I get "An error has occurred. Check your logs or contact the app author for clarification." (see also https://shinyapps.wiwi.hu-berlin.de/examples2 ).

Any ideas?

Sigbert


runtime: shiny
output: html_document

actionButton("run", "Run again")

Plot

renderPlot({
input$run
hist(rnorm(100))
})

Console

renderPrint({
input$run
x<-hist(rnorm(100))
x
})

Hi,

First of all, it's best to create a minimal reproducible example when having issues as your code is missing some parts to run it.

Second, you are trying to output a plot in a renderPrint statement. This doesn't make much sense to me... can you explain the purpose of this? Is it the values you're trying to print?

This is an example:

library(shiny)

ui <- fluidPage(
  actionButton("run", "Run again"),
  plotOutput("myPlot"),
  textOutput("myText")
)

server <- function(input, output, session) {
  
  myData = reactive({
    input$run
    rnorm(100)
  })
  
  output$myPlot = renderPlot({
    hist(myData())
  })
  
  output$myText = renderPrint({
    myData()
  })
}

shinyApp(ui, server)

Hope this helps,
PJ

minimal reproducible example

I embedded my markdown document. Unfortunately the interface here uses also (r)markdown syntax. I could not find a way to embed the rmarkdown document properly here.

This is an example:

I'am not interested in a shiny program, because I do not know what happens inside the shiny server when he renders an interactive document. I want that my interactive rmarkdown document runs properly not only in RStudio but on the shiny app server.

can you explain the purpose of this?

Because other people will use it as a template and I do not know what kind of code they will use.

Sigbert

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.