This file contains 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| | |
R_package_cmd << '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}\"'" |