1

I want my graphs, text and images to appear in a particular order as I am writing a data analysis project for university in R-Studio.

However, when I output to .pdf, the graphs, images and text appear jumpled up.

I was wondering if you would be able to help.

I have tried adding fig.show='hold' to the top of my code chunk.


Expected:

Heading1 Text1 Graph1 Image1

Heading2 Text2 Graph2 Image2

Heading3 Text3 Graph3 Image3

Actual:

Heading1 Text1 Graph3 Image1

Heading2 Text2 Graph2 Image2

etc.

In short, some graphs and images appear not in the same orders as the order I have constructed my document before knitting it to pdf.

  • Have you tried reordering the graph prints in your code to see how it would affect the outputs? The compare and contrast will probably suggest the ordering solution. – SteveM Mar 24 '19 at 18:15
  • Hi @SteveM, it seems that the order is dependent on the text I add. The more sentences I type changing the order of the graphs. It reminds me of text wrapping in Word. – R-you-ready Mar 24 '19 at 18:42
  • I am not sure, but since pdf knitting goes through LaTeX, the latter takes care of putting the figures where it thinks it's best. This will help you https://stackoverflow.com/questions/29696172/how-to-hold-figure-position-with-figure-caption-in-pdf-output-of-knitr – Ismail Müller Mar 24 '19 at 19:23
  • Thanks @IsmailMüller, once I finished writing my document, there was only one graph out of place which I was was able to live with. Thanks everyone. – R-you-ready Mar 25 '19 at 17:43

0 Answers0