0

When I plot in Rstudio the plots look good (as it should) but when I try to knit the .rmd file to render the .pdf file, labels, titles and axes disappear.

Plot in Rstudio:

rstudio

Plot in PDF:

plot_pdf

Any idea why?

Facts:

  • There are no error messages anywhere AT ALL
  • Equations are rendered ok
  • I use Ubuntu v20.04
  • I have Rstudio v2021.09.0 Build 351 "Ghost Orchid" Release (077589bc, 2021-09-20) for Ubuntu Bionic
  • with R v4.1.1 "Kick Things"

And I already tried the following:

  • Installed X11 package as shown since I read that was probably the issue
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fxlrg
sudo apt-get install xserver-xorg-core
sudo apt-get install xserver-xorg
sudo apt-get install xorg
sudo apt-get install xorg openbox
sudo apt-get install ubuntu-desktop
  • Installed texlive-latex-extra
  • Restarted Rstudio a million times

This is the configuration file

title: "knitting example"
author: "S_B04"
output:
  pdf_document:
    extra_dependencies:
    - bbm
    - xcolor
    toc: yes

This is the code that produces above chart:

# plotting cars data
plot(cars)

Thank you very much for any help! I'm adding the MRE as suggestion.

S_B04
  • 21
  • 3
  • Can you provide a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610)? With only as much code to just replicate the problem? (i.e. header and one simple plot using the `cars` data) – dario Oct 20 '21 at 08:11
  • Hey @dario I've added the MRE, thanks! – S_B04 Oct 22 '21 at 16:59
  • FYI: The example you posted does not reproduce your problem. You could (and probably should) include a MRE **that reproduces the report** (i.e. header . and one simple plot using the cars data). Additionally why did you include the ISLR package ? Is it necessary for your problem? If so, I won't be able to help anyways (bc I dont have that package) If it's not necessary: Why is it in the MRE? Consult the link above if you are not sure what constitutes a MRE... – dario Oct 23 '21 at 11:15
  • I added those two snippets that are the whole code in the file using cars data – S_B04 Oct 25 '21 at 16:39
  • Sorry but I don't see how this code could produce any output. There is at least code for the chunk missing. Again: The whole idea of the MRE is to make sure everyone here can reproduce the problem. What you provided is **not** a working reproducible example but just some fragments of code. If you can't create a pdf with the code you provide, how should I ? Anyhow, I don't see how I could help you using the information you provided... (What you could have done is create the smallest .Rmd that reproduces your problem and post that code. In its entirety, So that *anyone* can reproduce the pdf. – dario Oct 25 '21 at 19:40
  • I think you did not understand the issue which is in the first lines of the description. I have no problem generating the pdf file, probably comparing the two images there might help you understand it. The code provided is the minimum code needed to recreate the problem which again is in the description. But I think that if you can't understand the problem, recreate it, read it or solve it, well then simply don't answer probably someone else will. Thanks anyways @dario – S_B04 Oct 27 '21 at 04:06
  • You are mistaken, I understood the problem quite well. However, the code you provide does not reproduce the problem. (or any figure at all). But yea, probably someone else will be able ;) Best. D. – dario Oct 27 '21 at 07:12

0 Answers0