问题描述
我使用shiny编写了一个应用,在本地电脑上运行过程中没有出现问题,然后想要进行shinyapps部署,但是一直报错显示:
Error in value[[3L]](cond) : 不存在叫‘ggplot2’这个名字的程辑包
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
停止执行
或者显示报错:
Error in value[[3L]](cond) : 不存在叫‘shinythemes’这个名字的程辑包
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
停止执行
我的代码、示例数据和运行结果
在shiny中我也将所有需要载入的包都载入了:
library(shiny)
library(shinythemes)
library(shinyjs)
library(knitr)
library(reshape2)
library(plotly)
library(ggthemes)
library(grid)
library(Cairo)
library(curl)
library(ggplot2)
因为应用中涉及到中文,所以我参考了本站之前的帖子:
https://d.cosx.org/d/412685-shinyapps
和GitHub中的
https://github.com/rstudio/shiny-examples/tree/master/022-unicode-chinese
,将以下代码加入了app.R中:
# Cairo包的PNG设备似乎无法显示中文字符,强制使用R自身的png()设备
options(shiny.usecairo = FALSE)
# 请忽略以下代码,它只是为了解决ShinyApps上没有中文字体的问题
font_home <- function(path = '') file.path('~', '.fonts', path)
if (Sys.info()[['sysname']] == 'Linux' &&
system('locate wqy-zenhei.ttc') != 0 &&
!file.exists(font_home('wqy-zenhei.ttc'))) {
if (!file.exists('wqy-zenhei.ttc'))
curl::curl_download(
'https://github.com/rstudio/shiny-examples/releases/download/v0.10.1/wqy-zenhei.ttc',
'wqy-zenhei.ttc'
)
dir.create(font_home())
file.copy('wqy-zenhei.ttc', font_home())
system2('fc-cache', paste('-f', font_home()))
}
rm(font_home)
if (.Platform$OS.type == "windows") {
if (!grepl("Chinese", Sys.getlocale())) {
warning(
"You probably want Chinese locale on Windows for this app",
"to render correctly. See ",
"https://github.com/rstudio/shiny/issues/1053#issuecomment-167011937"
)
}
}
但是一直会出现像问题描述中的那些问题,希望哪位大佬能解惑,非常感谢!
我的系统环境
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] curl_4.3 Cairo_1.5-12.2 ggthemes_4.2.0 plotly_4.9.2.1 ggplot2_3.3.2 reshape2_1.4.4
[7] knitr_1.30 shinyjs_2.0.0 shinythemes_1.1.2 shiny_1.5.0
loaded via a namespace (and not attached):
[1] tinytex_0.26 tidyselect_1.1.0 xfun_0.18 purrr_0.3.4 colorspace_1.4-1 vctrs_0.3.4
[7] generics_0.0.2 htmltools_0.5.0 viridisLite_0.3.0 yaml_2.2.1 rlang_0.4.8 later_1.1.0.1
[13] pillar_1.4.6 glue_1.4.2 withr_2.3.0 lifecycle_0.2.0 plyr_1.8.6 stringr_1.4.0
[19] munsell_0.5.0 gtable_0.3.0 htmlwidgets_1.5.2 fastmap_1.0.1 httpuv_1.5.4 Rcpp_1.0.5
[25] xtable_1.8-4 openssl_1.4.3 promises_1.1.1 scales_1.1.1 jsonlite_1.7.1 mime_0.9
[31] askpass_1.1 digest_0.6.25 stringi_1.5.3 dplyr_1.0.2 tools_4.0.3 magrittr_1.5
[37] lazyeval_0.2.2 tibble_3.0.4 crayon_1.3.4 tidyr_1.1.2 pkgconfig_2.0.3 ellipsis_0.3.1
[43] rsconnect_0.8.16 data.table_1.13.4 httr_1.4.2 rstudioapi_0.11 R6_2.4.1 compiler_4.0.3