简体   繁体   English

Docker install.packages R on Ubuntu 22.04 找不到包

[英]Docker install.packages R on Ubuntu 22.04 packages not found

I have the docker command to install R packages:我有 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/')"

I get the error我得到错误

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/') Error in install.packages(c(readxl, zoo, plotly, RcppRoll, shiny, tidyverse, : object 'readxl' not found Execution halted 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/') install.packages(c(readxl, zoo, plotly, RcppRoll, shiny, tidyverse, : object 'readxl' not found Execution halted 错误

Where is the error?错误在哪里? R runs fine without docker. R 在没有 docker 的情况下运行良好。

You are falling victim to shell quoting, sometimes called shell quoting hell.您正在成为 shell 引用的受害者,有时称为 shell 引用地狱。 The fact that, as you say, "R runs fine without docker" just means you have the right command inside R, but not from the shell. Witness事实上,正如你所说,“R 在没有 docker 的情况下运行良好”只是意味着你在 R 中有正确的命令,但不是来自 shell。见证

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

but (method 1) escaping quotes works:但是(方法 1)escaping 引用有效:

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

or (method 2) wrapping double quotes in single quotes或(方法 2)用单引号将双引号括起来

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

So I would try所以我会尝试

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/")'

As an aside you may also want to look into r2u to have all this done as binaries (..) on Ubuntu 22.04 or 20.04.另外,您可能还想查看r2u以在 Ubuntu 22.04 或 20.04 上将所有这些作为二进制文件 (..) 完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM