我想要繪製在不同的面板動態圖,因爲它可以使用group
如的R - 如何繪製dygraphs在多個面板
的網站上完成,但它應該是動態的使用dygraphs。一個示例代碼在這裏:
library(quantmod)
library(dygraphs)
data(edhec)
R = edhec[, 1:4]
dygraph(R)
非常感謝提前。
我想要繪製在不同的面板動態圖,因爲它可以使用group
如的R - 如何繪製dygraphs在多個面板
的網站上完成,但它應該是動態的使用dygraphs。一個示例代碼在這裏:
library(quantmod)
library(dygraphs)
data(edhec)
R = edhec[, 1:4]
dygraph(R)
非常感謝提前。
要繪製多個dygraphs在同一RStudio窗口中,您必須首先創建的dygraphs對象列表,然後用包htmltools呈現dygraphs名單。 RStudio的Yihui Xie在這裏提供了答案: Yihui Xie answer(但沒有分組)。
這裏工作R
代碼產生分組dygraphs燭臺圖表:
# load packages
library(quantmod)
library(dygraphs)
library(htmltools)
# download time series into an environment
sym_bols <- c("VTI", "EEM")
data_env <- new.env()
quantmod::getSymbols(sym_bols, from="2017-01-01", env=data_env)
# create a list of dygraphs objects in a loop
dy_graph <- eapply(data_env, function(x_ts) {
dygraphs::dygraph(x_ts[, 1:4], group="etfs",
main=paste("Plot of:", substring(colnames(x_ts)[1], 1, 3)),
width=600, height=400) %>% dygraphs::dyCandlestick()
}) # end eapply
# render the dygraphs objects using htmltools
htmltools::browsable(htmltools::tagList(dy_graph))
# perform same plotting as above using pipes syntax
# create a list of dygraphs objects in a loop
eapply(data_env, function(x_ts) {
dygraphs::dygraph(x_ts[, 1:4], group="etfs",
main=paste("Plot of:", substring(colnames(x_ts)[1], 1, 3)),
width=600, height=400) %>% dygraphs::dyCandlestick()
}) %>% # end eapply
# render the dygraphs objects using htmltools
htmltools::tagList() %>% htmltools::browsable()
以上R
代碼產生以下分組dygraphs燭臺圖表:
感謝您快速回復!我以前見過這些,但我期望的是將其顯示在R/RStudio的繪圖窗口中。 –