The webshot package makes it easy to take screenshots of web pages from R. It requires an installation of the external program PhantomJS (you may use webshot::install_phantomjs() to install PhantomJS, if you do not want to download the binary and put it in PATH manually).

The main function in this package is webshot(). Below are some examples of taking screenshots of the website

# Clip to the viewport
webshot(URL, cliprect = "viewport")

# Manual clipping rectangle
webshot(URL, cliprect = c(200, 5, 400, 300))

# Using CSS selectors to pick out regions
webshot(URL, selector = ".list-group")

webshot(URL, selector = c("#features", "#installation"))

# Expand selection region
webshot(URL, selector = "#installation", expand = c(10, 50, 0, 50))

webshot("", selector = "ul.numbers-summary")

If you are familiar with JavaScript, you may run some JavaScript code on the page before taking the screenshot. Here is an example of logging into reddit:

You can also take screenshots of Shiny apps using the appshot() function, e.g.

There are two functions resize() and shrink() to manipulate images, which require GraphicsMagick (or ImageMagick) and OptiPNG, respectively. A simple example:

# Result can be piped to other commands like resize() and shrink()
webshot("", "r-small.png") %>%
 resize("75%") %>%