Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderIheatmap breaks when used with shiny::req #85

Open
daattali opened this issue Jun 23, 2021 · 3 comments
Open

renderIheatmap breaks when used with shiny::req #85

daattali opened this issue Jun 23, 2021 · 3 comments
Labels
bug maybe-fixed Issues that may or may not be resolved, if you think not then please say so

Comments

@daattali
Copy link

daattali commented Jun 23, 2021

Any shiny output should be able to "cancel" the output if a shiny::req() fails. It seems that renderIheatmap() results in an error when a req() fails:

error in evaluating the argument 'p' in selecting a method for function 'to_widget':

This is problematic because it means that shiny apps can't conditionally show a heatmap only when the required inputs are correct.

Example:

library(shiny)

ui <- fluidPage(
  numericInput("num", "num", 5),
  iheatmapr::iheatmaprOutput("heatmap")
)

server <- function(input, output, session) {
  output$heatmap <- iheatmapr::renderIheatmap({
    req(input$num > 3)
    iheatmapr::iheatmap(matrix(rnorm(input$num * 5), nrow = input$num))
  })
}

shinyApp(ui, server)

(If you change the number to be <= 3 you'll get an error)

@FabioBedin
Copy link

Is there still no solution for this problem?

@alanocallaghan
Copy link
Contributor

This (and other shiny issues raised by Dean) are on my to-do list but I've got a bunch of other projects that are higher priority, so it may take a while to get an 0.8 release out that fixes it. Any help (even if it's just pointing to docs on how to handle things properly) is likely to speed this up

alanocallaghan added a commit that referenced this issue Sep 3, 2023
@alanocallaghan
Copy link
Contributor

I've made a solution in the link branch (towards-0.8) that works for a reason I don't understand. Simply checking the class of the object before converting to a widget means that req works, at least in this example. Feel free to test if you need this feature

@alanocallaghan alanocallaghan added the maybe-fixed Issues that may or may not be resolved, if you think not then please say so label Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug maybe-fixed Issues that may or may not be resolved, if you think not then please say so
Projects
None yet
Development

No branches or pull requests

3 participants