嵌入rnetworkd3中的r markdown中,为什么此错误



我正在尝试将网络图添加到R Markdown文件写论文。我可以使用NetworkD3使图形使该图可视化。我想创建一个交互式HTML,但是我一直遇到错误。这是一个示例:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D")
target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I")
networkData <- data.frame(src, target)
simpleNetwork(networkData)
```

我会得到此错误,这与尝试嵌入自己的图表时遇到的错误非常相似。

processing file: w.Rmd
  |........                                                         |  12%
  ordinary text without R code
  |................                                                 |  25%
label: setup (with options) 
List of 1
 $ include: logi FALSE
  |........................                                         |  38%
label: unnamed-chunk-1
Quitting from lines 12-16 (w.Rmd) 
Error in eval(expr, envir, enclos) : 
  could not find function "simpleNetwork"
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval 
-> eval
Execution halted

您需要在设置中加载networkD3软件包,例如...

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(networkD3)
```
```{r}
src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D")
target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I")
networkData <- data.frame(src, target)
simpleNetwork(networkData)
```

我弄清楚了我在做什么错。我必须将数据加载到Markdown文件中。我在这里找到了答案https://support.rstudio.com/hc/en-us/community/posts/200631198-data-data-set-not-not-found-when-when-when-when-when-when-when-when-htting-html。

相关内容

  • 没有找到相关文章