hatmatrix
hatmatrix

Reputation: 44952

offline ggplot2 documentation?

This is not a programming question per se, but seeing as how R and ggplot2 are popular here I thought I'd ask if anyone knows if there is a way to download all of the documentation for ggplot2 at http://docs.ggplot2.org so that they can be accessed offline. I am frequently in a situation where internet access is not available.

Upvotes: 3

Views: 918

Answers (4)

Brian Diggs
Brian Diggs

Reputation: 58845

Another approach is to use the knit_rd() function in the knitr package. This takes the HTML version of the help pages, pulls out the examples, and runs them capturing the output (text or graphical) as knitr does. This will give you a directory of HTML files (and graphics) that can be viewed without a connection to the internet. It doesn't look exactly like the website created via staticdocs, but it has the same information, including worked examples and the graphical output of those examples.

Upvotes: 2

shirleywu
shirleywu

Reputation: 674

My response isn't R specific.

When you do have internet, you could manually opens each page and save them. For example, if you have Google Chrome (I am sure other browsers have their list of extensions), you can install either Awesome Screenshot: Capture & Annotate or Screen Capture (by Google) from the Chrome Web Store, then choose to capture entire page. There are also extension that lets you save the page as PDF file.

Upvotes: 3

Dason
Dason

Reputation: 61973

The page itself is created using Hadley's staticdocs package. You can run staticdocs on ggplot2 yourself to create the pages. You'll need the highlight package to install staticdocs. You can get that here or I hosted it on github for my convenience and you could get it with devtools with the commands

library(devtools)
install_github("highlight", "Dasonk")

to install staticdocs you can use devtools as well

install_github("staticdocs")

To run staticdocs you'll need the ggplot2 code and it's easiest to grab that with git. Assuming you're in a directory that you want the ggplot2 folder to be downloaded into you can use the following (assuming you have git installed).

git clone https://github.com/hadley/ggplot2.git

Alternatively you could grab the package source from the CRAN page and unpack that.

Make sure you have the suggested packages for ggplot2 (if you don't then staticdocs will exit abruptly once it hits an example it can't run because you don't have the suggested packages installed). If you're not sure if you have all the suggested packages it's easiest to just install ggplot2 using the dependencies=TRUE paramter.

install.packages("ggplot2", dependencies = TRUE)

then you can run staticdocs using the following:

library(staticdocs)
setwd("path/to/ggplot2/folder")
build_package(".", "inst/staticdocs")

Then you can find all the files you need in the inst/staticdocs subfolder and opening index.html will let you browse locally.

Note that using wget or some other method is probably a lot faster and lot easier once you get it to run. staticdocs takes quite a bit of time to run through completion and I didn't browse all the pages to make sure everything turned out alright. Another disadvantage of this method is that this runs based off the current developmental state of the package and so it might be a little ahead of what you actually have installed on your system.

Upvotes: 8

EDi
EDi

Reputation: 13300

What about the R Graphics Cookbook by Winston Chang?

Edit: Or using wget, as Ben Bolker suggests:

 wget --recursive --no-clobber --page-requisites --html-extension --convert-links   --restrict-file-names=windows --domains=docs.ggplot2.org  http://docs.ggplot2.org/current/

The --domains option should prevent to follow links outside of http://docs.ggplot2.org (like those at the bottom of the page). However I did not test that.

Upvotes: 9

Related Questions