Browser Version: Firefox 75.0 & Chrome 80.0.3987.162
Output of sessionInfo()
:
R version 3.6.1 (2019-07-05)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS
Matrix products: default
BLAS/LAPACK: /home/etienne/miniconda3/envs/R/lib/R/lib/libRblas.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=fr_FR.UTF-8
[3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=fr_FR.UTF-8 LC_NAME=fr_FR.UTF-8
[9] LC_ADDRESS=fr_FR.UTF-8 LC_TELEPHONE=fr_FR.UTF-8
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=fr_FR.UTF-8
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] shiny_1.4.0.2 forcats_0.5.0 stringr_1.4.0 dplyr_0.8.5
[5] purrr_0.3.3 readr_1.3.1 tidyr_1.0.2 tibble_3.0.0
[9] ggplot2_3.2.1 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] tidyselect_1.0.0 haven_2.2.0 lattice_0.20-40 colorspace_1.4-1
[5] vctrs_0.2.4 generics_0.0.2 htmltools_0.4.0 rlang_0.4.5
[9] pillar_1.4.3 later_1.0.0 glue_1.4.0 withr_2.1.2
[13] DBI_1.1.0 dbplyr_1.4.2 modelr_0.1.6 readxl_1.3.1
[17] lifecycle_0.2.0 munsell_0.5.0 gtable_0.3.0 cellranger_1.1.0
[21] rvest_0.3.5 fastmap_1.0.1 httpuv_1.5.2 fansi_0.4.1
[25] broom_0.5.5 Rcpp_1.0.4 xtable_1.8-4 scales_1.1.0
[29] backports_1.1.5 promises_1.1.0 jsonlite_1.6.1 mime_0.9
[33] fs_1.3.2 hms_0.5.3 digest_0.6.25 stringi_1.4.3
[37] grid_3.6.1 cli_2.0.2 tools_3.6.1 magrittr_1.5
[41] lazyeval_0.2.2 crayon_1.3.4 pkgconfig_2.0.3 ellipsis_0.3.0
[45] xml2_1.2.2 reprex_0.3.0 lubridate_1.7.4 assertthat_0.2.1
[49] httr_1.4.1 rstudioapi_0.11 R6_2.4.1 nlme_3.1-145
[53] compiler_3.6.1
Example 1 :
runExample("01_hello")
Example 2 :
runExample("04_mpg")
Example 3 : (from the shiny reference )
# A basic shiny app with a plotOutput
shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel(
actionButton("newplot", "New plot")
),
mainPanel(
plotOutput("plot")
)
)
),
server = function(input, output) {
output$plot <- renderPlot({
input$newplot
# Add a little noise to the cars data
cars2 <- cars + rnorm(nrow(cars))
plot(cars2)
})
}
)
Hello,
My problem : I cannot get any plot showing. No error is displayed, all other widgets and outputs are correctly rendered, but not plots.
I have tried the following :
but the results remain the same.
The problem is related to this one. (I am also using a version of R installed with conda, but I do not understand why that makes shiny plots fail to display).
And in my case, the Firefox developper console shows :
SyntaxError: JSON.parse: expected double-quoted property name at line 1 column 10523 of the JSON data.
dispatchMessage shinyapp.js:421
onmessage shinyapp.js:83
I have searched for similar issues, but I did not find any working solution. Any idea is welcome.
Thanks in advance.
I'm encountering the same issue. I'd be thankful for solutions or referrals to other communities that might be able to help. Thanks!
Hello,
I did not find the solution with conda. You can try installing R and shiny without conda , I think it should work (although I have not tried).
Thanks for the quick reply! Yes, it does indeed work without using conda. However, it would be ideal to find a way that allows me to keep the current setup. So while there is a workaround for the meantime, I still hope for an answer.
If you know how to use Docker and are able to provide a Dockerfile that reproduces the problem, that would help us to debug it.
If you can capture the malformed JSON that's being processed by dispatchMessage
in the browser, and post it here or in a gist, that would also help. You may be able to do it by opening your web browser's JavaScript console and having pause on exceptions. Before running your app, run options(shiny.minified=FALSE)
so that it uses the original non-minified JS code (this will make debugging easier).
Thanks for the answer! Unfortunately, I'm not familiar with Docker.
I'm also not very familiar with the JavaScript Console, but I think I found the JSON object in question. I put it in this gist.
Here's a weird part in the (escaped) JSON that @schloerke found:
{\"left\":40,88,\"right\":98,12,\"bottom\":-1,08,\"top\":28,08}
The value for left
should be 40.88
, I think, and not 40,88
. There may be some strange locale stuff going on. Can you provide the output of:
Sys.getlocale()
sessioninfo::session_info()
And can you provide the output of these commands:
jsonlite::toJSON(list(x = 40.88), auto_unbox = T)
shiny:::toJSON(list(x = 40.88))
Sure!
> Sys.getlocale()
[1] "de_DE.UTF-8"
> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.6.1 (2019-07-05)
os Ubuntu 18.04.4 LTS
system x86_64, linux-gnu
ui RStudio
language de_DE:en_US:en
collate de_DE.UTF-8
ctype de_DE.UTF-8
tz Europe/Berlin
date 2020-05-21
─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
cli 2.0.2 2020-02-28 [1] CRAN (R 3.6.1)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
digest 0.6.25 2020-02-23 [1] CRAN (R 3.6.1)
fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.1)
fastmap 1.0.1 2019-10-08 [1] CRAN (R 3.6.1)
glue 1.3.2 2020-03-12 [1] CRAN (R 3.6.1)
htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.1)
httpuv 1.5.2 2019-09-11 [1] CRAN (R 3.6.1)
jsonlite 1.6.1 2020-02-02 [1] CRAN (R 3.6.1)
later 1.0.0 2019-10-04 [1] CRAN (R 3.6.1)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
mime 0.9 2020-02-04 [1] CRAN (R 3.6.1)
promises 1.1.0 2019-10-04 [1] CRAN (R 3.6.1)
R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.1)
Rcpp 1.0.4 2020-03-17 [1] CRAN (R 3.6.1)
rlang 0.4.5 2020-03-01 [1] CRAN (R 3.6.1)
rstudioapi 0.11 2020-02-07 [1] CRAN (R 3.6.1)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.1)
shiny * 1.4.0.2 2020-03-13 [1] CRAN (R 3.6.1)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
xtable 1.8-4 2019-04-21 [1] CRAN (R 3.6.0)
yaml 2.2.1 2020-02-01 [1] CRAN (R 3.6.1)
> jsonlite::toJSON(list(x = 40.88), auto_unbox = T)
{"x":40.88}
> shiny:::toJSON(list(x = 40.88))
{"x":40,88}
Thanks! Can you provide the output from:
Sys.getlocale("LC_NUMERIC")
> Sys.getlocale("LC_NUMERIC")
[1] "de_DE.UTF-8"
I can reproduce the behavior with:
withr::with_locale(
c(LC_NUMERIC = "de_DE"),
jsonlite::toJSON(list(x = 40.88), auto_unbox = T, digits = NA)
)
#> Warning message:
#> In (function (category = "LC_ALL", locale = "") :
#> setting 'LC_NUMERIC' may cause R to function strangely
#> {"x":40,88}
withr::with_locale(
c(LC_NUMERIC = "C"),
jsonlite::toJSON(list(x = 40.88), auto_unbox = T, use_signif = T)
)
#> Warning message:
#> In (function (category = "LC_ALL", locale = "") :
#> setting 'LC_NUMERIC' may cause R to function strangely
#> {"x":40.88}
(shiny:::toJSON()
is a wrapper function that calls jsonlite::toJSON()
.)
In the documentation for Sys.setlocale
, it says:
Setting "LC_NUMERIC" to any value other than "C" may cause R to function anomalously, so gives a warning. Input conversions in R itself are unaffected, but the reading and writing of ASCII save files will be, as may packages which do their own input/output.
I think what's happening that conda is setting the locale to "de_DE"
, which it is not supposed to do. You should probably run this when you start up R:
Sys.setlocale("LC_NUMERIC", "C")
That said, jsonlite::toJSON()
is producing malformed output when that locale setting is used, and that is a bug, so I'll file an issue there.
Thanks a lot! Setting the locale to "C" did actually solve the problem.
Most helpful comment
I can reproduce the behavior with:
(
shiny:::toJSON()
is a wrapper function that callsjsonlite::toJSON()
.)In the documentation for
Sys.setlocale
, it says:I think what's happening that conda is setting the locale to
"de_DE"
, which it is not supposed to do. You should probably run this when you start up R:That said,
jsonlite::toJSON()
is producing malformed output when that locale setting is used, and that is a bug, so I'll file an issue there.