For loop-over-dygraph在R中不起作用

For loop-over-dygraph在R中不起作用,r,r-markdown,dygraphs,R,R Markdown,Dygraphs,dygraph上有一些奇怪的行为 当使用for循环for动态图时,我没有得到任何结果 library(dygraphs) lungDeaths <- cbind(mdeaths, fdeaths) for(i in 1:2){ dygraph(lungDeaths[, i]) } 实际上,我想在自己的数据集上使用R标记中的for循环,并迭代不同的列,但即使使用lappy“变通方法”,它也不会绘制dygraphs R降价代码 --- title: "Untitled" author:

dygraph
上有一些奇怪的行为

当使用
for
循环for
动态图时,我没有得到任何结果

library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)

for(i in 1:2){
  dygraph(lungDeaths[, i])
}
实际上,我想在自己的数据集上使用
R标记中的
for
循环,并迭代不同的列,但即使使用
lappy
“变通方法”,它也不会绘制
dygraphs

R降价代码

---
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]))
```

只需将
lappy()
的列表输出包装在
htmltools::tagList()
中即可

```{r}
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
res <- lapply(1:2, function(i) dygraph(lungDeaths[, i]))
htmltools::tagList(res)
```
`{r}
图书馆(动态图)

肺死亡对于任何一个在循环中挣扎的人来说,以下是对我有效的方法

p=list()
for (n in 1:3){
  p[[n]] <- plot_ly(x = 1:100, y = rnorm(100)+n, mode = 'lines', type="scatter")
}
htmltools::tagList(p)
p=list()
对于(1:3中的n){

p[[n]
lappy
markdown
中对我起作用。至于
for loop
,你可以通过
show(dygraph(lungdeath[,i]))来解决这个问题(效率低下的方法)
谢谢你研究这个问题。不幸的是,对我来说这两个都不起作用。我将用
sessionInfo()更新我的问题
我使用的是相同的R版本加上'0.4.3'动态图版本。这里也一样。这很奇怪。我在两台不同的机器上试用过它,但仍然存在问题。当我在
for loop
工作中说
lappy
show
选项时,我的意思是我只能在
查看器
中看到,而不是在
html
中看到。可能是这样吗与
dynamic chart
有关。你可以就此向软件包维护人员发送电子邮件。谢谢,你的导师。如果你想对这个答案添加一些注释,比如它是否是重复的答案,你可以将它放在你答案下面的注释中。附加提示:必须使用RenderyGraph而不是RenderyGraph。
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

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

other attached packages:
[1] dygraphs_0.4.3 devtools_1.7.0

loaded via a namespace (and not attached):
[1] htmltools_0.2.6 tools_3.2.0     yaml_2.1.13     rmarkdown_0.6.1 digest_0.6.8 
```{r}
library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
res <- lapply(1:2, function(i) dygraph(lungDeaths[, i]))
htmltools::tagList(res)
```
p=list()
for (n in 1:3){
  p[[n]] <- plot_ly(x = 1:100, y = rnorm(100)+n, mode = 'lines', type="scatter")
}
htmltools::tagList(p)