有一些奇怪的行为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) 我想使用dygraph一次绘制多个图(它们不必在第一步中同步)
基础R-例子:
temperature <- ts(frequency = 12, start = c(1980, 1),
data = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5,
25.2, 26.5, 23.3, 18.3, 13.9, 9.6))
rainfall <- ts(frequency = 12, start = c(1980, 1),
data = c(49.9, 71.5, 106.4, 129.2, 144.0, 176.0,
135.6, 148.5, 216.4, 194.1, 95.6, 54.4))
par(mfrow = c(2, 1))
plot(temperature)
plot(rainfall)
Run Code Online (Sandbox Code Playgroud)
使用dygraph这种方法不起作用
require(dygraphs)
par(mfrow = c(2, 1))
dygraph(temperature)
dygraph(rainfall)
Run Code Online (Sandbox Code Playgroud)
我知道有可能显示第二轴等.但也许有人知道一次显示两个图的答案
我正在运行以下 RSTUDIO 帮助页面提供的 dygraph 示例。
http://rstudio.github.io/dygraphs/gallery-synchronization.html
当我运行以下代码时,我会分别获得每个 dygraph 的单独图。
dygraph(ldeaths, main = "All", group = "lung-deaths")
dygraph(mdeaths, main = "Male", group = "lung-deaths")
dygraph(fdeaths, main = "Female", group = "lung-deaths")
Run Code Online (Sandbox Code Playgroud)
我没有得到帮助页面中显示的同步图。"group" 变量 "lung-deaths" 不是 xts 对象的一部分。如果我在这里遗漏了一些基本的东西,请告诉我。
谢谢
普拉迪普
我使用生成交互式图形dygraph.我可以在R studio的"Viewer"窗口和浏览器中查看它们.
保存这些图的最方便的方法是什么(es html?)?我可以邮寄吗?
我运行R studio 0.98.507并
sessionInfo()给出:
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=German_Austria.1252 LC_CTYPE=German_Austria.1252 LC_MONETARY=German_Austria.1252 LC_NUMERIC=C
[5] LC_TIME=German_Austria.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] PerformanceAnalytics_1.1.0 xts_0.9-7 zoo_1.7-11 MASS_7.3-33
[5] cluster_1.15.2 RODBC_1.3-10
loaded via a namespace (and not attached):
[1] grid_3.1.0 lattice_0.20-29 tools_3.1.0
Run Code Online (Sandbox Code Playgroud)