Assuming that you already have the R statistics program installed on your Mac, the following can be used to install a package from the command line.
First, get the .tgz file (we'll use plotrix as the package we want to install):
$ curl http://cran.r-project.org/bin/macosx/universal/contrib/r-release/plotrix_2.6-1.tgz > plotrix_2.6-1.tgz
Check that R is properly installed:
$ which R
/usr/bin/R
Install the package: