Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Let MacTeX find Sweave.sty with R 2.8

R 2.8 changed the default way that the Sweave package files were linked to. It used to hardcode the location into the resulting .tex file, but now just inserts

\usepackage{Sweave}


So, we need to tell MacTeX where to find the Sweave style files. Assuming you've installed R and MacTeX from the package installers

mkdir -p ~/Library/texmf/tex/latex 
cd ~/Library/texmf/tex/latex 
ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave 


This will create a link from your user's tex directory to the Sweave files from R.

Install RdbiPgSQL package for R on OS X

Connecting R to Postgres on OS X is a little bit of a hassle given where OS X looks for the libraries to link to.

Assuming you've installed Postgres via MacPorts, then install Rdbi as you would normally.

source("http://bioconductor.org/biocLite.R")
biocLite("Rdbi")


Then grab the RdbiPgSQL package source:

cd /tmp
curl -O http://bioconductor.org/packages/2.5/bioc/src/contrib/RdbiPgSQL_1.20.0.tar.gz


Pass in the location of your Postgres libraries and include files to the INSTALL command using --config-args

sudo R CMD INSTALL --configure-args='--with-pgsql-libraries=/opt/local/lib/postgresql84 --with-pgsql-includes=/opt/local/include/postgresql84' RdbiPgSQL_1.20.0.tar.gz