I prefer to not mess with pgfpages and its settings in the presentation source itself, but let an external tool, such as pdfnup, generate the (often various) x-up versions I need with or without borders, distances, scaling:

\documentclass[10pt,handout,onlymath]{beamer}
\usepackage{pgffor}
\usefonttheme{serif}
\begin{document}

\foreach \x in {1,...,7} {\begin{frame}{Title \x}The frame number \x\end{frame}}

\end{document}


If you compile this with:

pdflatex presentation.tex
pdfnup --no-landscape --nup 2x4 --frame true --no-tidy --delta '5mm 5mm' --scale 0.95 presentation.pdf


The result will be a file presentation-nup.pdf that looks as follows:

 

A plus of this approach is that this does not interfere with other LaTeX packages that also affect the shipout-level. textpos, for instance, is incompatible to pgfpages, even though it is mentioned in the beamer userguide as the way to go for absolute positioning.

Beamer handout: Problem when creating border around frames
Frequently I am running R scripts in bash mode. My script is called 981_conduct_regression.R. In this script, I call required packages with

if(!require(&lt;package&gt;)){
  install.packages("&lt;package&gt;")
  library(&lt;package&gt;)
}


Now when I call the script from bash mode (on Ubuntu 14.04), the script (shown below) fails to install the packages: 

Loading required package: gridExtra
Installing package into ‘/home/michael/R/x86_64-pc-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
Error in contrib.url(repos, type) : 
  trying to use CRAN without setting a mirror
Calls: source ... eval -&gt; eval -&gt; install.packages -&gt; grep -&gt; contrib.url
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘gridExtra’
Execution halted


What do I have to change for my idea to work?

Edit: Here is the .sh file:

#!/bin/bash

Rscript Code/981_conduct_regression.R

