Skip to content

Instantly share code, notes, and snippets.

@pgr0ss
pgr0ss / support.rb
Last active December 15, 2015 07:48
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}\"'"