r语言 - "function %>% not found" - DPLYR包已加载



我目前正在尝试通过shinyproxy与docker结合运行我的r-application -不幸的是没有成功。

通过R-Studio启动应用程序时没有问题。然而,只要我创建Docker映像并尝试调用它,我就会得到错误消息&;function %>% not found"。

我认为包没有正确加载,但我不能说为什么。在我的Docker文件中,我引用了一个"installlibraries . r"文件,其中包含应用程序所需的所有库。我还调整了rProfile文件,以便每个R会话都应该加载所有库。

对于一个类似的应用程序,它不那么广泛(但具有几乎相同的dockerfile以及applications.yml),通过shinyproxy和docker托管没有任何问题....

哒你可以找到我的Docker文件,我的个人档案。网站,我的申请。和我的installlibraries。

也许有人知道我还能做些什么。如果您需要更多信息,请随时与我联系!: -)

谢谢你并致以最良好的问候

注:我知道很多图书馆都是"封闭的"。在其他的和不必要的加载-我还没有抽出时间排序:D


Rprofile.site

##                      Emacs please make this -*- R -*-
## empty Rprofile.site for R on Debian
##
## Copyright (C) 2008 - 2018  Dirk Eddelbuettel and GPL'ed
##
## see help(Startup) for documentation on ~/.Rprofile and Rprofile.site
# ## Example of .Rprofile
# options(width=65, digits=5)
# options(show.signif.stars=FALSE)
# setHook(packageEvent("grDevices", "onLoad"),
#         function(...) grDevices::ps.options(horizontal=FALSE))
# set.seed(1234)
# .First <- function() cat("n   Welcome to R!nn")
# .Last <- function()  cat("n   Goodbye!nn")
# ## Example of Rprofile.site
# local({
#  # add MASS to the default packages, set a CRAN mirror
#  old <- getOption("defaultPackages"); r <- getOption("repos")
#  r["CRAN"] <- "http://my.local.cran"
#  options(defaultPackages = c(old, "MASS"), repos = r)
#})
## We set the cloud mirror, which is 'network-close' to everybody, as default
local({
r <- getOption("repos")
r["CRAN"] <- "https://cloud.r-project.org"
options(repos = r)
})
library("shiny")
library("rwhatsapp") 
library("dplyr")     
library("stringr")    
library("grid")       
library("gridExtra")  
library("cowplot")    
library("magick")     
library("ggmap")      
library("stopwords")  
library("tidytext")   
library("stringi")    
library("ggplot2")
library("tidyr")
library("lubridate")
library("ggtext")
library("lattice")
library("extrafont")
library("showtext")
library("ggfittext")
library("sysfonts")
library("png")
library("shinyBS")
library("shinyWidgets")
library("bslib")
library("shinycustomloader")
library("magrittr")
library("knitr")

installPackages。R

r = getOption("repos")
r["CRAN"] = "http://cran.us.r-project.org"
options(repos = r)

install.packages("shiny")
install.packages("rwhatsapp") 
install.packages("dplyr")     
install.packages("stringr")    
install.packages("grid")       
install.packages("gridExtra") 
install.packages("cowplot")    
install.packages("magick")     
install.packages("ggmap")      
install.packages("stopwords")  
install.packages("tidytext")   
install.packages("stringi")    
install.packages("ggplot2")
install.packages("tidyr")
install.packages("lubridate")
install.packages("ggtext")
install.packages("lattice")
install.packages("extrafont")
install.packages("showtext")
install.packages("ggfittext")
install.packages("sysfonts")  
install.packages("png")
install.packages("googleway")
install.packages("shinyBS")
install.packages("shinyWidgets")
install.packages("bslib")
install.packages("shinycustomloader")
library(shiny)
library(rwhatsapp)  
library(dplyr)      
library(stringr)    
library(grid)       
library(gridExtra)  
library(cowplot)    
library(magick)     
library(ggmap)      
library(stopwords)  
library(tidytext)  
library(stringi)    
library(ggplot2)    
library(tidyr)     
library(lubridate)  
library(ggtext)     
library(lattice)    
library(extrafont)    
library(showtext)
library(ggfittext)
library(sysfonts)
library(png)
library(googleway)
library(shinyBS)
library(shinyWidgets)
library(bslib)
library(shinycustomloader)

Dockerfile

FROM rocker/r-base:latest
LABEL maintainer="USER <user@example.com>"
RUN apt-get update && apt-get install -y --no-install-recommends 
sudo 
libcurl4-gnutls-dev 
libgtk2.0-dev
xvfb
xauth
xfonts-base
libcairo2-dev 
libxt-dev 
libssl-dev 
libssh2-1-dev 
libxml2-dev 
libmagick++-dev
&& rm -rf /var/lib/apt/lists/*
RUN install.r shiny
RUN echo "local(options(shiny.port = 3838, shiny.host = '0.0.0.0'))" > /usr/lib/R/etc/Rprofile.site
RUN addgroup --system app 
&& adduser --system --ingroup app app
WORKDIR /home/app
COPY app .
RUN Rscript installPackages.R
RUN chown app:app -R /home/app
USER app
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/home/app')"]

application.yml

proxy:
title: ShinyProxy
#  logo-url: https://link/to/your/logo.png
landing-page: /
favicon-path: favicon.ico
heartbeat-rate: 10000
heartbeat-timeout: 600000
port: 8080
container-wait-time: 60000
admin-groups: admins
hide-navbar: true
# Docker configuration
docker:
cert-path: /home/none
url: http://localhost:2375
port-range-start: 20000
specs:
- id: 01_hello
display-name: Hello Shiny App
description: A simple reactive histogram
container-image: #######:latest
logo-url: ########
access-groups: [admins, users]

logging:
file:
shinyproxy.log
spring:
servlet:
multipart:
max-file-size: 2000MB
max-request-size: 2000MB

我找到解决办法了。

我在ui.r文件的开头加载了所有的库——不是通过函数,而是直接加载的。这并没有使代码更好,但它可以工作:D

最新更新