找不到Ubuntu 22.04上的Docker安装包R

yrdbyhpb  于 2023-01-28  发布在  Docker
关注(0)|答案(1)|浏览(223)

我使用docker命令来安装R包:

RUN R -e "install.packages(c("readxl","zoo","plotly","RcppRoll","shiny","tidyverse"\
,"shinyWidgets","shinythemes","metR","writexl","shinydashboard","lubridate","sjmisc"\
,"DBI","dplyr","dbplyr","odbc"), repos='https://cloud.r-project.org/')"

我得到了错误
安装包(c(readxl,zoo,plotly,RcppRoll,shiny,tidyverse,shinyWidgets,shinythemes,metR,writexl,shinydashboard,lubridate,sjmisc,DBI,dplyr,dbplyr,odbc),repos ="https://cloud.r-project.org/")安装包时出错(c(readxl,zoo,plotly,RcppRoll,shiny,tidyverse,:未找到对象'readxl'执行已停止
错误在哪里?R在没有Docker的情况下运行良好。

pw9qyyiw

pw9qyyiw1#

你正在成为shell引用的牺牲品,有时候被称为shell引用地狱。事实上,正如你所说的,“R运行良好,没有docker”只是意味着你在R中有正确的命令,但不是来自shell。

$ Rscript -e "cat("Hello, world\n")"
Error: unexpected end of input
Execution halted
$

但是(方法1)转义引号有效:

$ Rscript -e "cat(\"Hello, world\n\")"
Hello, world
$

或(方法2)将双引号括在单引号中

$ Rscript -e 'cat("Hello, world\n")'
Hello, world
$

所以我会试着

RUN R -e 'install.packages(c("readxl","zoo","plotly","RcppRoll","shiny", 
          "tidyverse",    "shinyWidgets","shinythemes","metR","writexl",
          "shinydashboard","lubridate","sjmisc", "DBI", "dplyr", 
          "dbplyr", "odbc"), repos="https://cloud.r-project.org/")'

顺便说一句,你可能还想看看r2u,让所有这些都在Ubuntu 22.04或20.04上作为二进制文件(!!)完成。

相关问题