After updating to R 4.4.0, many different data visualizations that depend on the htmlwidgets
library, such as leaflet
, echarts4r
and highcharter
, fail to render in the R Studio Viewer pane. These visualizations do show up in the Viewer pane if I instead use my previous installation of R 4.3.3. I’m assuming that htmlwidgets
is the source of the issue, as RMarkdown and Quarto document previews show up without an issue in the Viewer pane, but I could be wrong.
Strangely, when I save the results as an HTML page and open them, the data visualizations work perfectly.
If I inspect the Viewer pane using Developer Tools, I can see that all my data exists inside a selector called <script type="application/json" data-for="htmlwidget-90458e179f447c2a160e">
. When I look at the Console tab, I can see that there are several .js
resources with the following error message: Failed to load resource: net::ERR_SOCKET_NOT_CONNECTED
.
Thus far, similar questions that I’ve seen posted on Stack Overflow were resolved by installing the latest version of R Studio OR were related to encountering a similar issue on website pages, not inside R Studio’s Viewer pane. I have already updated to the “Chocolate Cosmos” release of R Studio (RStudio/2024.04.0+735) and the issue persists. This is the output I am trying to achieve (and which appears when I export the output to HTML):
Whereas here is an example data set to illustrate what currently happens (note: the citytemp_long
data set comes an example data set pre-loaded into highcharter
):
library(highcharter)
hchart(
citytemp_long,
"line",
hcaes(x = month, y = temp, group = city)
)
Unfortunately, this results in an empty (or invisible?) plot.
The issue is not exclusive to highcharter
, as leaflet
and echarts4r
also show the same empty outputs. I’ve included my sessionInfo()
as well to try to help identify the source of the problem.
sessionInfo()
#> R version 4.4.0 (2024-04-24 ucrt)
#> Platform: x86_64-w64-mingw32/x64
#> Running under: Windows 10 x64 (build 19045)
#>
#> Matrix products: default
#>
#>
#> locale:
#> [1] LC_COLLATE=English_United States.utf8
#> [2] LC_CTYPE=English_United States.utf8
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=English_United States.utf8
#>
#> time zone: America/Chicago
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] styler_1.10.2 digest_0.6.35 fastmap_1.1.1 xfun_0.43
#> [5] magrittr_2.0.3 glue_1.7.0 R.utils_2.12.3 knitr_1.46
#> [9] htmltools_0.5.8.1 rmarkdown_2.26 lifecycle_1.0.4 cli_3.6.2
#> [13] R.methodsS3_1.8.2 vctrs_0.6.5 reprex_2.1.0 withr_3.0.0
#> [17] compiler_4.4.0 R.oo_1.26.0 R.cache_0.16.0 purrr_1.0.2
#> [21] rstudioapi_0.16.0 tools_4.4.0 evaluate_0.23 yaml_2.3.8
#> [25] rlang_1.1.3 fs_1.6.4
Created on 2024-05-01 with reprex v2.1.0