Installation script to add packages from Cran R

If you use the free software cran R to do data analysis and you are also that kind of person that likes to have the last version then you may be interested in this.  Many times i compile the last version of Cran R from scratch but have the problem that many packages are not automatically available for that version yet, the only solution is to download and compile them manually which is a lot of effort given all the dependencies.

I know that this is not a great solution, but it saved me a lot of time, it can be improved.

First you will need an index from the packages, you can create it so:

wget "" -O pkgs.txt

And then you will have to run these lines a few times until all the dependencies are installed:

while [[ `cat /tmp/err | grep ERRO | wc -l` -ne 0 ]]; do
 i=`cat /tmp/err | grep "ERROR" | sed 's/.*dependenc[a-z]\{1,4\} //g' | sed 's/’ [are |is ].*//g' | sed 's/[,’‘]//g' | cut -f1 -d" "`;
 echo "Installing dependency $i";
 PP=`cat pkgs.txt | grep "^${i}_"`;
 if [ ! -e $PP ]; then wget "$PP" -O $PP; fi;
 echo "Installing ${PP}";
 R CMD INSTALL ${PP} 2> /tmp/err;

If you want to install the “ggplot2” package, just put the package name in the variable “INSTALAR” and run the script.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s