aws-lambda-r
aws-lambda-r copied to clipboard
Which is the best way to install R packages?
On the Amazon AMI I can install from inside R, but then I have this problem: Installing package into ‘/usr/lib64/R/library’ (as ‘lib’ is unspecified) Warning in install.packages("jsonlite", repos = "http://cran.r-project.org") : 'lib = "/usr/lib64/R/library"' is not writable Would you like to use a personal library instead? (y/n)
I can install it this way also: wget https://cran.r-project.org/src/contrib/jsonlite_1.5.tar.gz sudo R CMD INSTALL jsonlite_1.5.tar.gz
which probably is the best way, or run R as sudo..
Packages to be installed are supposed to be listed in the variable R_PACKAGES
(originally defined in settings_default.sh
).
The code to install them is located in the second part of the script 11_install_packages.sh
which indicates the lib
path, etc.
Yes, I read the code in all the files under /scripts, but I could not find out how exactly how it's supposed to work and which syntax to use.
how exactly how it's supposed to work
In setup_user.sh
define a variable R_PACKAGES
as shown in settings_default.sh
. For example:
# do not use commas or quotes, leave spaces before and after each package name
R_PACKAGES=( jsonlite purrr digest )
Then, you can run the main script 01_main.sh
.
If you want to use the auto-setup, run any of scripts 21_setup_vpc.sh
, 22_setup_custom_ami.sh
, 23_setup_s3.sh
, 24_setup_lambda.sh
, as needed before runnig the main script.
Great! Thanks! I only intend to use 11 and 12 (or if it was 13..). Then shut the EC2 down and develop on my local computer with AWS SAM. I already have aws-sam-cli, R and Python on my Mac, so I just have to invoke the phyton lambda to see that it works and then deploy it.
Unfortunately, the python aws sam has bugs that stop that scenario.