Define width of plot in flexdashboards

Hi all,

I have a very simple dashboard with two columns, using R Markdown with flexdashboard which I then publish to RPubs.

In the first column there is text and in the second a graph. I have customised the column width using {data-width=400} and {data-width=900} respectively, and the plot width using {data-width=900}. It works in the preview window, but then in RPubs it remains at the default size. You can see it at the following link:

You can see that the graph remains small, when there is a lot of unused space on the right which I would like the graph to fill and thus be clearer.

I would be very grateful for some help.

Cheers!

Jerome

Hi Jerome and welcome to RStudio Community :partying_face: :partying_face: :partying_face: :partying_face:

Instead of previewing your dashboard in the preview window of RStudio, I suggest you preview it in your local browser first. Do you obtain the desired result?

Hi Gueyenono,

Thank you for your welcome!

I tried many different options, and finally "solved" it with a workaround: I just eliminated flexdashboards and created a plain R Markdown HTML page (with only one column of course). To get the graph to the right size I used the following code:

knitr::opts_chunk$set(fig.width=9, fig.height=6)

I wonder if anyone else has had trouble using flexdashboards with RPubs?

Cheers,
Jerome

Are you implying that knitr::opts_chunk$set(fig.width=9, fig.height=6) would not work if the output format is flexdashboard? It should in principle.

It is possible this is linked to Rpubs which I think embeded the file into a templated website with navbar and all. RPubs has it own navbar and footer and there has already been issues on mobile with flexdashboard and RPubs.

However, this is just a guess as I can't reproduce and I don't have your published example anymore.

It would require a reproducible example to look more into that.

1 Like