R - how to build graphs in several panels

I tried to display a dynamic graph in different panels, how can this be done on a website using group , for example enter image description here

but it must be dynamic using digraphs. Sample code here:

 library(quantmod) library(dygraphs) data(edhec) R = edhec[, 1:4] dygraph(R) 

Thank you very much in advance.

+2
source share
2 answers

Create multiple diagrams using the synchronization function here

To view it as a single document, you need knit to create an HTML page. Take a look at this fooobar.com/questions/993947 / ... answer for details.

Your end result will look like this .

+5
source

To build several digraphs in one RStudio window, you must first create a list of dygraphs objects and then display a list of dygraphs using the htmltools package. Yihui Xie from RStudio provided the answer here: Answer Yihui Xie (but without grouping).

Here the R code works, which creates diagrams of highlighted grouped diagrams:

 # 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() 

The R code above creates the following highlighted graphical charts:

enter image description here

0
source

All Articles