Rendering R books to EPUB using Quarto

Sam Parmar
2 min readAug 14, 2022

--

Cat with glasses reading on Macbook laptop
https://giphy.com/gifs/computer-cat-wearing-glasses-VbnUQpnihPSIgIXuZv

Here are the steps I followed to render the Quarto version of Hands on Programming with R into an EPUB for easy use with Apple Books (my reading app of choice). The same process could be applied to other Quarto books that you are reading the HTML version of, to get them into a EPUB or PDF format.

Note that I encourage you to buy a physical copy of the book to support the author(s) if you do this.

  1. Clone the book’s Github repository as R project into RStudio.
  2. Run render from command line or R console. Read documentation before running.
  3. The new output file should be available in a subdirectory. Follow the path printed in the Terminal or Background Jobs pane.

Creating a project from Github with {usethis}.

usethis::create_from_github(“GITHUB REPO URL GOES HERE")

Rendering from terminal (in the R project) requires the output format to be specified via the--to argument. Documentation on publishing from terminal is here.

quarto render --to epub

Alternatively, in the R console, this also works (assuming you’re in the project). Documentation on the render function from the quarto R package is here.

quarto::quarto_render(output_format = "epub")

The following output formats are supported: HTML, PDF, MS Word, EPUB. So, if you prefer a PDF, that output format should also be accessible. I’d recommend using {renv} to install the book’s package dependencies. Note that this assumes all the book dependencies such as packages and datasets are publicly accessible to successfully render output. It also requires you to install the packages on your machine to successfully render the book.

Once again, I encourage you to buy a physical copy of the book to support the author(s) if you do this.

--

--

Sam Parmar
Sam Parmar

No responses yet