Using specific versions of R packages in docker file


#1

Hi everyone, I’m new to Shiny Proxy and am doing my best, yet have recently run into an obstacle. I’ve prepared a docker file and am attempting to spin up an image. I need to use specific versions for several packages. I’ve tried to use the install_version() command, from the devtools package, but I get the following error.

Error: unexpected numeric constant in "install_version(‘readxl’, version = 1.0.0"
Execution halted
The command '/bin/sh -c R -e "install_version(‘readxl’, version = “1.0.0”, dependencies= T, repos='https://cloud.r-project.org/’)"’ returned a non-zero code: 1

The docker file that produces this error is as follows:

FROM openanalytics/r-base

MAINTAINER John Smith “exampleemail”

system libraries of general use

RUN apt-get update && apt-get install -y
sudo
pandoc
pandoc-citeproc
libcurl4-gnutls-dev
libcairo2-dev
libxt-dev
libssl-dev
libssh2-1-dev
libssl1.0.0

system library dependency for the TSK app

RUN R -e “install.packages(c(‘hms’,‘devtools’))”

RUN R -e “require(devtools)”

RUN R -e “install_version(‘readxl’, version = “1.0.0”, dependencies= T)”
RUN R -e “install_version(‘DT’, version = “0.2”, dependencies= T)”
RUN R -e “install_version(‘shinydashboard’, version = “0.6.1”, dependencies= T)”
RUN R -e “install_version(‘knitr’, version = “1.18”, dependencies= T)”
RUN R -e “install_version(‘magrittr’, version = “1.5”, dependencies= T)”
RUN R -e “install_version(‘ggrepel’, version = “0.7.0”, dependencies=T)”
RUN R -e “install_version(‘dplyr’, version = “0.7.4”, dependencies=T)”
RUN R -e “install_version(‘Rcpp’, version = “0.12.14”, dependencies=T)”
RUN R -e “install_version(‘rhandsontable’, version = “0.3.4”, dependencies=T)”
RUN R -e “install_version(‘shinyjs’, version = “0.9.1”, dependencies=T)”
RUN R -e “install_version(‘V8’, version = “0.2.0”, dependencies=T)”
RUN R -e “install_version(‘data.table’, version = “1.10.4-3”, dependencies=T)”
RUN R -e “install_version(‘packrat’, version = “0.4.8-1”, dependencies=T)”
RUN R -e “install_version(‘zoo’, version = “1.8-1”, dependencies=T)”
RUN R -e “install_version(‘shiny’, version = “1.0.5.9000”, dependencies=T)”
RUN R -e “install_version(‘rmarkdown’, version = “1.8”, dependencies=T)”
RUN R -e “install_version(‘kableExtra’, version = “0.3.0”, dependencies=T)”

copy the app to the image

RUN mkdir /root/tsk
COPY tsk /root/tsk

COPY Rprofile.site /usr/lib/R/etc/

EXPOSE 3838

CMD [“R”, “-e”, “shiny::runApp(’/root/tsk’)”]

I would be so grateful for any advice with this (please note that I deleted the
repos = https://cloud.r-project.org/ argument for the install_version() calls above, because new users can only include 2 hyperlinks in a post entry here).

With warm wishes,

Tim


#2

Hello Tim,
You get the error because you have used double quotes inside double quoted string.
So it can easily be fixed by replacing
RUN R -e "install_version('readxl', version = "1.0.0", dependencies= T)"
lines with
RUN R -e "install_version('readxl', version = '1.0.0', dependencies= T)"


#3

Thanks so much Maxim, I really appreciate it :):grinning: