有一些奇怪的行为dygraph.
使用for循环时,dygraph我没有结果.
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
for(i in 1:2){
dygraph(lungDeaths[, i])
}
Run Code Online (Sandbox Code Playgroud)
另一方面,当我使用lapply我确实得到预期的结果
lapply(1:2, function(i) dygraph(lungDeaths[, i]))
Run Code Online (Sandbox Code Playgroud)
我实际上想在我自己的数据集中使用for循环R Markdown并迭代不同的列,但即使我使用lapply"解决方法",它也不会绘制dygraphs
R Markdown代码
---
title: "Untitled"
author: "dimitris_ps"
date: "28 May 2015"
output: html_document
---
```{r}
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
lapply(1:2, function(i) dygraph(lungDeaths[, i]))
```
Run Code Online (Sandbox Code Playgroud)
而当我逐列运行它时,它的工作原理
---
title: "Untitled"
author: "dimitris_ps"
date: "28 May 2015"
output: html_document
---
```{r echo=FALSE}
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths) …Run Code Online (Sandbox Code Playgroud)