'trelliscopejs R package only one trelliscope figure visible in html file
I am having a problem rendering more than one trelliscopejs
displays in an html file created with Rmarkdown. I'm using self_contained=TRUE
in order to render displays in html. The problem is that only the first display is rendered correctly: whereas the rest of them is rendered as blank spaces: I'm using some examples from official tutorial. The whole .rmd file is posted below:
---
title: "Testy trelliscopejs"
author: "balkon16"
date: "22 lipca 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(message = FALSE, warning = FALSE) #suppress ggplot2 warnings
```
```{r}
library(trelliscopejs)
library(ggplot2)
library(dplyr)
```
```{r}
library(tidyr)
library(rbokeh)
d <- mpg %>%
group_by(manufacturer, class) %>%
nest() %>%
mutate(panel = map_plot(data,
~ figure(xlab = "City mpg", ylab = "Highway mpg") %>%
ly_points(cty, hwy, data = .x)))
d
```
```{r}
d %>%
trelliscope(name = "city_vs_highway_mpg", self_contained = TRUE)
```
```{r}
mpg %>%
group_by(manufacturer, class) %>%
summarise(
mean_city_mpg = cog(mean(cty), desc = "Mean city mpg"),
mean_hwy_mpg = cog(mean(hwy), desc = "Mean highway mpg"),
panel = panel(
figure(xlab = "City mpg", ylab = "Highway mpg",
xlim = c(7, 37), ylim = c(9, 47)) %>%
ly_points(cty, hwy,
hover = data_frame(model = paste(year, model),
cty = cty, hwy = hwy)))) %>%
trelliscope(name = "city_vs_highway_mpg", nrow = 1, ncol = 2,
self_contained = TRUE)
```
```{r}
qplot(x = 0, y = cty, data = mpg, geom = c("boxplot", "jitter")) +
facet_trelliscope(~ class, ncol = 7, height = 800, width = 200,
state = list(sort = list(sort_spec("cty_mean"))), self_contained = TRUE) +
ylim(7, 37) + theme_bw()
```
It seems that I'm using the newest version of trelliscopejs
as devtools::install_github("hafen/trelliscopejs")
returns:
Skipping install of 'trelliscopejs' from a github remote, the SHA1 (4be901e4) has not changed since last install.
Use `force = TRUE` to force installation
Here's my session info:
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Polish_Poland.1250 LC_CTYPE=Polish_Poland.1250
[3] LC_MONETARY=Polish_Poland.1250 LC_NUMERIC=C
[5] LC_TIME=Polish_Poland.1250
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Cairo_1.5-9 bindrcpp_0.2.2 dplyr_0.7.6 ggplot2_3.0.0.9000
[5] trelliscopejs_0.1.13 rbokeh_0.5.0 tidyr_0.8.1
loaded via a namespace (and not attached):
[1] progress_1.2.0 gistr_0.4.2 tidyselect_0.2.4
[4] purrr_0.2.5 lattice_0.20-35 colorspace_1.3-2
[7] htmltools_0.3.6 yaml_2.1.19 base64enc_0.1-3
[10] utf8_1.1.3 rlang_0.2.1 hexbin_1.27.2
[13] pillar_1.2.2 glue_1.3.0 withr_2.1.2
[16] pryr_0.1.4 bindr_0.1.1 plyr_1.8.4
[19] stringr_1.3.1 munsell_0.4.3 gtable_0.2.0
[22] devtools_1.13.5 htmlwidgets_1.2 memoise_1.1.0
[25] codetools_0.2-15 evaluate_0.10.1 labeling_0.3
[28] knitr_1.20 curl_3.2 Rcpp_0.12.17
[31] scales_0.5.0 backports_1.1.2 checkmate_1.8.5
[34] DistributionUtils_0.5-1 webshot_0.5.0 jsonlite_1.5
[37] hms_0.4.2 digest_0.6.15 stringi_1.1.7
[40] grid_3.5.1 rprojroot_1.3-2 cli_1.0.0
[43] tools_3.5.1 magrittr_1.5 maps_3.3.0
[46] lazyeval_0.2.1.9000 autocogs_0.0.1 tibble_1.4.2
[49] crayon_1.3.4 pkgconfig_2.0.1 rsconnect_0.8.8
[52] prettyunits_1.0.2 assertthat_0.2.0 rmarkdown_1.10
[55] httr_1.3.1 rstudioapi_0.7 R6_2.2.2
[58] mclust_5.4.1 git2r_0.21.0 compiler_3.5.1
Solution 1:[1]
I found the following works.
You need to do two things in the facet_trelliscope function:
- Specify the path variable. For each facet_trelliscope specify one unique folder.
- Set self_contained be TRUE.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alan |