Installing R packages with Packer

(platform = AWS Amazon Linux 2)

Trying to create an entry in packer.json to install the R shiny package. The command line to install is:

sudo su -
-c “R -e “install.packages(‘shiny’, repos=‘https://cran.rstudio.com/’)””

But this doesn’t work in the packer build file, even when I insert " at the beginning and ", at the end. I know it can work, just need the proper syntax.

Suggestions?

We wrote an Rscript to do that, it looks something like this:

#!/usr/bin/env Rscript
install.packages(c(
  "httr",
  "sf",
  "tigris",
  "rvest",
  "xml2",
  "units",
  "DBI",)
  repo = "https://cloud.r-project.org")

We then copy it with the file provisioner and execute it at boot time.