2

Based on this question here and the answers provided, I created the following code to plot multiple FX dygraphs. The fig.width and fig.height for the Rmarkdown document are specified in the code chunk. However, when the graphs are created in the lapply function format the height refers back to standard heights.

library("quantmod")
library("dygraphs")
library("dplyr")

FX_Names <- c("DEXUSEU","DEXUSUK","DEXUSAL","DEXUSNZ")
FXOV <- lapply(FX_Names, function(x) getSymbols(x,src='FRED',auto.assign = FALSE)) %>% 
do.call(merge.xts,.)

```{r,fig.width=10,fig.height=2,eval=T}
dygraph_list <- lapply(1:4, function(i)
dygraph(FXOV['2010/',i])) 
htmltools::tagList(dygraph_list)
```  

This is not the case when the plots are created after one another as given below

```{r,fig.width=10,fig.height=2,eval=T}
dygraph(FXOV['2010',1]) 
dygraph(FXOV['2010/',2])
dygraph(FXOV['2010/',3])
dygraph(FXOV['2010/',4])
```

Any suggestions?

Community
  • 1
  • 1
New_code
  • 594
  • 1
  • 5
  • 16

1 Answers1

0

I was trying to solve a similar issue, solved by writing a function that creates a dygraph and wraps it with a div which has a style = "display:inline-block;" property.

see the full conversation with myself and a sample code here

yurikleb
  • 180
  • 10