2

visNetwork在下面的 ioslides 演示文稿中,该图对我来说是空白的,但它使用 Slidy 和reveal.js 渲染得很好。我已经尝试过最新的 CRAN 和开发版本htmlwidgetsrmarkdown.

---
title: "slides"
output: ioslides_presentation
---

## The HTML widget should render.

```{r}
library(visNetwork, quietly = TRUE)
visNetwork(data.frame(id = 1:3), data.frame(from = c(1,2), to = c(1,3)))
```

我宁愿在我当前的演示文稿中坚持使用 ioslides,因为我需要一些不坚持显示.js 的自定义 CSS。

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.9 (Santiago)

Matrix products: default
BLAS: /opt/R/R-3.4.0/lib64/R/lib/libRblas.so
LAPACK: /opt/R/R-3.4.0/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] devtools_1.13.2

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.11         revealjs_0.9         digest_0.6.12        withr_1.0.2         
 [5] rprojroot_1.2        R6_2.2.2             backports_1.1.0      git2r_0.18.0        
 [9] magrittr_1.5         evaluate_0.10        highr_0.6            httr_1.2.1          
[13] stringi_1.1.5        curl_2.6             rmarkdown_1.6.0.9001 tools_3.4.0         
[17] stringr_1.2.0        yaml_2.1.14          rsconnect_0.8        compiler_3.4.0      
[21] memoise_1.1.0        htmltools_0.3.6      knitr_1.16 

编辑 2019-05-12

@Esteban Moro,widgetframe绝对有帮助。不过,至少在我这边,还有工作要做。下面,我展示iotest.Rmd了 ,它会生成一个空的iotest_files. 有任何想法吗?

---
title: "slides"
output: ioslides_presentation
---

## The HTML widget should render.

```{r}
library(visNetwork, quietly = TRUE)
library(widgetframe)
frameWidget(visNetwork(data.frame(id = 1:3), data.frame(from = c(1,2), to = c(1,3))))
```

在此处输入图像描述

> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS:   /home/landau/R/R-3.6.0/lib/libRblas.so
LAPACK: /home/landau/R/R-3.6.0/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] widgetframe_0.3.1 htmlwidgets_1.3   visNetwork_2.0.6 

loaded via a namespace (and not attached):
 [1] compiler_3.6.0  magrittr_1.5    htmltools_0.3.6 tools_3.6.0    
 [5] yaml_2.2.0      Rcpp_1.0.1      rmarkdown_1.12  knitr_1.22     
 [9] jsonlite_1.6    xfun_0.6        digest_0.6.18   evaluate_0.13 

编辑 2019-05-13

我在 YAML 前面的问题上试过selfcontained: false了,但小部件仍然没有出现。的结果相同selfcontained: true

---
title: "slides"
output:
  ioslides_presentation:
    selfcontained: false
---

## The HTML widget should render.

```{r}
library(visNetwork, quietly = TRUE)
library(widgetframe)
frameWidget(visNetwork(data.frame(id = 1:3), data.frame(from = c(1,2), to = c(1,3))))
```

在此处输入图像描述

4

2 回答 2

2

对于 ioslides,我使用widgetframeR 中的库解决了它

library(visNetwork, quietly = TRUE)
library(widgetframe)
frameWidget(visNetwork(data.frame(id = 1:3), data.frame(from = c(1,2), to = c(1,3))))

编辑 05-15-2019

这是一个适用于我的最小示例:

---
title: "slides"
output: 
  ioslides_presentation:
    self_contained: FALSE
---

```{r setup, include=F}
knitr::opts_chunk$set(widgetframe_widgetsdir = 'widgets')
library(visNetwork, quietly = TRUE)
library(widgetframe)
```


## The HTML widget should render.
```{r}
frameWidget(visNetwork(data.frame(id = 1:3), 
                       data.frame(from = c(1,2), to = c(1,3))))
```
于 2019-05-12T10:07:07.520 回答
0

这似乎是由于Hammer.jsioslides 中的(旧?)使用与vis.js.

真的不知道怎么解决……!

于 2017-08-01T10:08:38.890 回答