Rendering R books to EPUB using Quarto

Cat with glasses reading on Macbook laptop

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store