Created
March 26, 2013 14:22
-
-
Save braintreeps/5245725 to your computer and use it in GitHub Desktop.
Capistrano task for automatically installing a list of R libraries during an automated deployment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "install R packages" | |
task :install_R_packages do | |
R_packages = File.read("#{release_path}/R_packages.txt").lines.map { |line| line.strip } | |
R_package_cmd = R_packages.map do |package| | |
'if(!require(\"'+package+'\")){ install.packages(\"'+package+'\",lib=c(\"'+shared_path+'/R\"), repos=\"http://cran.cnr. | |
berkeley.edu/\"); };' | |
end.join(' ') | |
sudo "sh -c 'if [ ! -d #{shared_path}/R ]; then mkdir #{shared_path}/R; fi'" | |
sudo "sh -c 'export R_LIBS_USER=#{shared_path}/R && R --vanilla -e \"#{R_package_cmd}\"'" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment