-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
jsonlite warning with shiny 1.4.0 #2673
Comments
Similar experience with any single x axis item:
|
Also receiving this warning whenever x-axis is reduced to single factor. |
I am getting this warning message when I use |
@kaijagahm Can you file a new issue, with a minimal reproducible example? For the others that have experienced this issue, when I run the example apps, I don't see the message. It's possible that it has been fixed since the issue was originally filed. If you still see that message, please provide the output of |
I am not sure this issue is limited to ggplot. I have the same warning whenver I the value argument is a named vector. The problem is there even in shiny 1.6 (session info below). Once I put I'd prefer if the update-function would just ignore the names in the vector. library(shiny)
ui <- fluidPage(
titlePanel("as JSON Warning Sample"),
mainPanel(
sliderInput("inpSlider", "Just another value", 1, 10, 5),
actionButton("btnReset", "Reset to 1")
)
)
server <- function(input, output, session) {
observeEvent(
input$btnReset,
{ # NAMED VECTOR CAUSES THE WARNING
updateSliderInput(session, "inpSlider", value = c(a = 1))
})
}
shinyApp(ui = ui, server = server)
|
…r." (see [Shiny issue #](rstudio/shiny#2673))
@SigurdJanson Thanks for that example. This is a difficult (or really, almost impossible) problem to fix in general, because of R's nature as a loosely-typed language. The root issue is that jsonlite doesn't like named atomic vectors when
In contrast, named lists are fine:
In the examples posted previously, it seems that something in ggplot2 generated data with named atomic vectors. In @SigurdJanson's example, it's the call to In Shiny, we do some input validation, we don't check every possible input for every possible kind of invalid value. (It's similar to the vast majority of R code in this way.) With a strongly-typed language, many checks just happen automatically; with a loosely-typed language like R, deciding which things to check (and whether to "fix" them for the user) is much more subjective. |
Is there any option for a workaround here? This issue is making it impossible to label graphs other than using a legend. The functions ggrepel::geom_label_repel and ggplot2::geom_label also seem to throw the same error once reactive inputs are used.
|
Hi @lbramley, I just tried your app and can reproduce the error. There's a rather long message that's printed, for me it's the following:
That second-to-last line about
which occur because you need to use the same data frame for p <- ggplot(mtcars_disp,
- aes(wt, mpg, label = rownames(mtcars), colour = factor(cyl))) +
+ aes(wt, mpg, label = rownames(mtcars_disp), colour = factor(cyl))) +
geom_point() |
Thanks @gadenbuie! Really helpful to know that the |
@gadenbuie Is the asJSON error happening when attempting to JSON-serialize a fancy rlang error? I have a vague feeling like those fancy errors need to be accounted for in Shiny's catch-error-during-output-render logic. |
@jcheng5 Maybe? That also feels likely to me too, although it doesn't seem to be going through shiny's internal |
I also get a warning when renderPlot, but if I activate the shiny from R not radian, everything goes well |
Just saw this while trying to debug some code. See #4167 for a reprex if it helps. |
Hello,
Consider this app:
When you select the radio button "boxplot", this message appears in the R console:
It is caused by
x = ""
in theaes
. If I remove this argument, there's no warning anymore.This message didn't appear with
shiny < 1.4.0
.The text was updated successfully, but these errors were encountered: