2
votes

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?

1
Chances to get a response are better if you remove all irrelevant lines (everything from Options to axis) and provide a dummy data set to make the example self-containedDieter Menne
thanks for the suggestions. Will add the data and shorten the codeNew_code
From which library is getSymbols?Dieter Menne

1 Answers

0
votes

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