xlim ylim error when plotting in Shiny

883 views
Skip to first unread message

Trevor Paulsen

unread,
May 9, 2013, 6:12:24 PM5/9/13
to shiny-...@googlegroups.com
I've found an unusual error I can't figure out when using the following plot command:

        xVar = input$bubbleX
        yVar = input$bubbleY
        rows = dim(summaryTable)[1]
        cols = dim(summaryTable)[2]

        x=2
        y=2

       symbols(summaryTable[x,1:(cols-1)], summaryTable[y,1:(cols-1)], sqrt(summaryTable[1,1:(cols-1)]/pi), inches = 1, fg="white", bg="blue", xlab = xVar, ylab = yVar)
       text(summaryTable[x,1:(cols-1)], summaryTable[y,1:(cols-1)], c(1:(cols-1)), cex=1, col="white")


This plot works fine for me in a normal R plot and in the Shiny render just fine.

However, if I change x and y to be

        x = as.numeric(which(numericVarNames == xVar) + 1)
        y = as.numeric(which(numericVarNames == yVar) + 1)

(which in this case each of those expressions evaluate to 2 as well) I get "Error: need finite 'xlim' values" when trying this in Shiny, but the plots work just fine from the R console.  Clearly, I'm not getting the difference between a normal R plot and a Shiny plot.

Any ideas what might be wrong?

Thanks,
Trevor

Winston Chang

unread,
May 10, 2013, 12:16:18 AM5/10/13
to shiny-...@googlegroups.com
Hard to say without the full app... One thing you can do is add a line with 'browser()' right above the plot code. When it reaches that line, it'll pause the app and drop you into a normal R debugger session, where you can inspect the variables.

One thought: is it possible that input$bubbleX is a giving you a string instead of a number?

-Winston



--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Trevor Paulsen

unread,
May 10, 2013, 11:55:39 AM5/10/13
to shiny-...@googlegroups.com
Actually, I figured it out finally.  I was using a renderUI in a tab and found that the selectInput that was passed to the renderUI did not actually render until I selected the tab.  So, the x and y values were not available on page load, hence the error.

Winston Chang

unread,
May 10, 2013, 2:15:14 PM5/10/13
to shiny-...@googlegroups.com
By default, outputs (including renderUI/uiOutput) are suspended when they're not visible -- you may find it useful to disable this behavior in your case. In your server code you could have something like this:

output$ui_out <- renderUI({ ... })

outputOptions((output, 'ui_out', suspendWhenHidden=FALSE)

-Winston


Trevor Paulsen

unread,
May 10, 2013, 2:34:56 PM5/10/13
to shiny-...@googlegroups.com
Ah, very useful.  Thanks!


--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/ULwRFD0Iet8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages