Skip to content

Instantly share code, notes, and snippets.

@pgr0ss
Last active December 15, 2015 07:48
Show Gist options
  • Save pgr0ss/5225680 to your computer and use it in GitHub Desktop.
Save pgr0ss/5225680 to your computer and use it in GitHub Desktop.
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}\"'"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment