发布闪亮应用程序时出现问题 - renderWidget(instance) 中的警告:忽略附加内容;不能在闪亮的渲染调用中使用appendContent

2024-05-04

我在尝试发布 Shiny 应用程序时收到以下错误。这是我的第一个应用程序。我在网上搜索无法弄清楚问题是什么。下面的错误消息来自我尝试在线发布时。应用程序的完整代码位于错误消息下方。在笔记本电脑上,该应用程序可以运行,但我无法在shinyapps.io 网站上在线部署。请帮忙!

Failed to create bus connection: No such file or directory
Warning in system("timedatectl", intern = TRUE) :
  running command 'timedatectl' had status 1
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✔ ggplot2 3.3.3     ✔ purrr   0.3.4
✔ tibble  3.1.0     ✔ dplyr   1.0.5
✔ tidyr   1.1.3     ✔ stringr 1.4.0
✔ readr   1.4.0     ✔ forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()

Attaching package: ‘DT’

The following objects are masked from ‘package:shiny’:

    dataTableOutput, renderDataTable

Linking to GEOS 3.5.1, GDAL 2.2.2, PROJ 4.9.2
Error in value[[3L]](cond) : invalid string in PangoCairo_Text
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

这是下面的应用程序的代码:

#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
#    http://shiny.rstudio.com/
#

library(shiny)
library(tidyverse)
library(leaflet)
library(DT)
library(tmap)
library(sf)

#Load all the data you want to visualize
#Import data and clean it
windturbine <- read.csv("windturbine.csv")
windturbine_df<- windturbine[!is.na(windturbine$latitude), ]
windturbine_df<- windturbine[!is.na(windturbine$longitude), ]

windturbine_sf<-
    st_as_sf(windturbine, coords = c("longitude","latitude"), 
             crs = "+proj=longlat +datum=WGS84 +no_defs") %>% 
    st_transform(crs = "+proj=lcc +lon_0=-90 +lat_1=33 +lat_2=45")

#Subset data you want in table
wind_data<-windturbine_df %>%
    select(province_territory,project_name,total_project_capacity_mw,turbine_identifier,turbine_number_in_project,turbine_rated_capacity_k_w,rotor_diameter_m,hub_height_m,manufacturer,model,commissioning_date)
turbinesperprovince <-windturbine %>%
    group_by(factor(province_territory))%>%
    count()
names(turbinesperprovince)<-c("province_territory","total_turbines")

#Total wind turbines per province
provinceplot=windturbine %>% 
    count(province_territory) %>% 
    ggplot(aes(forcats::fct_reorder(province_territory, n), n)) +
    geom_bar(stat="identity", fill="steelblue") +
    ggtitle("Number of Turbines for Each Province") +
    coord_flip() +
    theme_minimal() +
    ylab('Number of Turbines') +
    xlab('Province')

#Save the plot
ggsave("provinceplot.png",width = 297,height = 210,units = c("mm"),dpi = 300)

#Total wind turbines per project 
projectplot=windturbine %>% 
    count(project_name) %>% 
    filter(n > 50)%>% 
    ggplot(aes(forcats::fct_reorder(project_name, n),n)) +
    geom_bar(stat="identity", fill="steelblue") +
    ggtitle("Number of Turbines for Each Project")+
    coord_flip() +
    theme_minimal() +
    ylab('Number of Turbines') +
    xlab('Project')

#Save the plot
ggsave("projectplot.png",width = 297,height = 210,units = c("mm"),dpi = 300)

projects <- windturbine %>% 
    group_by(project_name) %>% 
    summarize(capacity = mean(total_project_capacity_mw),
              rotor_diameter = median(rotor_diameter_m),
              hub_height = median(hub_height_m),
              province_territory = province_territory,
              commissioning_date = commissioning_date,
              manufacturer = manufacturer) %>% 
              unique()

provincelist <- list(  "Alberta"= "Alberta","British Columbia"= "British Columbia","Manitoba"= "Manitoba",                 
            "New Brunswick"= "New Brunswick","Newfoundland and Labrador"= "Newfoundland and Labrador",
            "Northwest Territories"= "Northwest Territories",  
            "Nova Scotia"="Nova Scotia", "Ontario"= "Ontario",
            "Prince Edward Island"= "Prince Edward Island",    
            "Quebec"="Quebec")

# Define UI for application that draws a histogram
ui <- fluidPage(navbarPage("Wind turbines in Canada",id="main",
                           #tabPanel("Home",includeHTML("readme.html")),
                           tabPanel("Map", leafletOutput("turbinemap",height=1000)),
                           navbarMenu("Data Tables",
                                tabPanel("All data",DT::dataTableOutput("table")),
                                tabPanel("View projects per province",
                                         sidebarLayout(
                                             sidebarPanel(selectInput("selection","Select a province to view", choices =provincelist, selected = 'Alberta')),
                                             mainPanel(h4('Project summary by province'),tableOutput("summary"))
                                         ))),
                           tabPanel("Plots",
                                sidebarLayout(
                                    sidebarPanel(
                                        radioButtons("plottype", "Plot projects",
                                        choices=c("By Province" = "province","By Project" = "project")
                                        )
                                ),
                            mainPanel(plotOutput("turbinePlots")                        
                                ),
                                ))))

    
                        

# Define server logic required to draw a histogram
server <- function(input, output) {

    output$table <- renderDataTable(datatable(
    wind_data,filter = 'top',
    colnames = c("Province", "Project name", "Total project capacity(MW)", "Turbine identifier", "Turbine No.in Project", "Turbine rated capacity(kW)","Rotor diameter(m)",
                 "Hub height(m)","Manufacturer","Model","Commissioning date")
    ))
    output$summary <- renderTable({
        subset(projects,province_territory == input$selection)
    })
    
    output$turbinemap <- renderLeaflet({
    mymap <-tm_shape(windturbine_sf) + 
        tm_dots(col="indianred1",popup.vars=c("Project Name"="project_name","Total project capacity(MW)"="total_project_capacity_mw"))
    tmap_leaflet(mymap)
   })
    
    output$turbinePlots <- renderPlot({
    if (input$plottype == "province"){
        windturbine %>% 
            count(province_territory) %>% 
            ggplot(aes(forcats::fct_reorder(province_territory, n), n)) +
            geom_bar(stat="identity", fill="steelblue") +
            ggtitle("Number of Turbines for Each Province") +
            coord_flip() +
            theme_minimal() +
            ylab('Number of Turbines') +
            xlab('Province')
        
    } else if (input$plottype == "project"){
        windturbine %>% 
            count(project_name) %>% 
            filter(n > 50)%>% 
            ggplot(aes(forcats::fct_reorder(project_name, n),n)) +
            geom_bar(stat="identity", fill="steelblue") +
            ggtitle("Number of Turbines for Each Project")+
            coord_flip() +
            theme_minimal() +
            ylab('Number of Turbines') +
            xlab('Project')}
    }, height = 800)
    
}
        
# Run the application 
shinyApp(ui = ui, server = server)


尝试设置in.shiny = TRUE在 - 的里面tmap_leaflet()功能。例如

output$turbinemap <- renderLeaflet({
    mymap <-tm_shape(windturbine_sf) + 
        tm_dots(col="indianred1",popup.vars=c("Project Name"="project_name","Total project capacity(MW)"="total_project_capacity_mw"))
    tmap_leaflet(mymap, in.shiny = TRUE)
   })

默认情况下此参数设置为FALSE。两个特点在tmap_leaflet(){shiny} 不支持,并且设置in.shiny = TRUE禁用这些功能并停止警告。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

发布闪亮应用程序时出现问题 - renderWidget(instance) 中的警告:忽略附加内容;不能在闪亮的渲染调用中使用appendContent 的相关文章

  • R 中的龙卷风图

    我正在尝试在 R 中绘制龙卷风图 又名敏感性图 目标是可视化某些变量增加 10 和减少 10 的效果 到目前为止我已经得到这个结果 这是我正在使用的代码 Tornado plot data lt matrix c 0 02 0 02 0 0
  • 使用 RDCOMClient 搜索 Outlook 收件箱

    我尝试使用 RDCOMClient 在 Outlook 收件箱中搜索电子邮件中的特定主题 然后获取附件 我在一封电子邮件上进行了这项工作 但由于主题包含日期元素 我需要搜索成为一个类似的子句 但不太清楚这适合我的下面的查询 outlook
  • 如何从 R 数据框中提取关键字

    我是 R 中文本挖掘的新手 我想从数据框的列中删除停用词 即提取关键字 并将这些关键字放入新列中 我尝试制作一个语料库 但它对我没有帮助 df C3是我目前拥有的 我想添加栏目df C4 但我无法让它工作 df lt structure l
  • 读取R中打开的Excel文件

    有没有办法将打开的Excel文件读入R 当Excel中打开一个excel文件时 Excel会对文件加锁 比如R中的read方法无法访问该文件 你能绕过这个锁吗 Thanks 编辑 这发生在带有原始 Excel 的 Windows 下 发生错
  • 如何自动启动我的 ec2 实例、运行命令然后将其关闭?

    我想每周对 redshift postgres 数据库中的数据运行一次机器学习模型 我使用以下命令将 R 脚本设置为休息 apiplumbr然后我将其设置为一项任务来管理pm2 我有它 所以任务会在ec2实例启动然后继续运行 要让 R 脚本
  • 不同 R/lme4 版本的单一拟合结果不匹配

    我试图将 R 版本 3 5 3 lme4 1 1 18 1 的随机效应估计与 R 版本 4 1 1 lme4 1 1 27 1 相匹配 然而 当存在奇异拟合时 这两个版本之间的随机效应存在微小差异 我对奇点警告很满意 但令人费解的是不同版本
  • 如何绘制大时间序列(数千次给药次数/药物剂量)?

    我正在尝试绘制医院中如何开出单一药物的图解 在这个虚拟数据库中 我在 2017 年 1 月 1 日之后遇到了 1000 名患者 绘图的目的是了解该药物的给药模式 在接近入院 出院或患者住院期间是否更频繁 高剂量给药 Get random d
  • 从日期变量创建月末日期

    我有一个包含日期变量的大型数据框 它反映了该月的第一天 有没有一种简单的方法来创建代表该月最后一天的新数据框日期变量 以下是一些示例数据 date start month seq as Date 2012 01 01 length 4 by
  • 如何在 Caret 中绘制随机森林(护林员)树

    我生成了如下所示的随机森林树 并尝试绘制它 但出现错误 我在哪里犯了错误 我怎样才能以正确的方式绘制它 Actmodel lt train Activity Section Author data CB1 method ranger trC
  • R、Rcpp 与 Armadillo 中矩阵 rowSums() 与 colSums() 的效率

    背景 来自 R 编程 我正在扩展到 C C 形式的编译代码Rcpp 作为循环交换 以及一般的 C C 效果的实践练习 我实现了 R 的等效项rowSums and colSums 矩阵的函数Rcpp 我知道它们以 Rcpp 糖的形式存在 并
  • 在 R 传单中添加不透明度滑块

    如何在 R leaflet 应用程序中添加滑块来控制特定图层的不透明度 对于这个应用程序 我不想使用闪亮 这里建议 在 R 传单应用程序中添加滑块 https stackoverflow com questions 37682619 add
  • 将字符串列拆分为多个虚拟变量

    作为 R 中 data table 包的相对缺乏经验的用户 我一直在尝试将一个文本列处理为大量指示符列 虚拟变量 每列中的 1 表示特定的子字符串是在字符串列中找到 例如我想处理这个 ID String 1 a b 2 b c 3 c 进入
  • 将 ftransform 与折叠 R 包中的 fgroup_by 一起使用

    我正在尝试重现以下输出dplyr代码与R包裹collapse dplyr Code library tidyverse starwars gt select name mass species gt group by species gt
  • R - 计算 bin 中特定值的数量

    我有一个如下所示的数据框 df Value lt c 1 1 0 2 1 3 4 0 0 1 2 0 3 0 4 5 2 3 0 6 Sl lt c 1 20 df lt data frame Sl Value gt df Sl Value
  • Quantmod 的简单功能不再起作用

    我明天要交论文 我收到了一条关于 quantmod 的非常奇怪的错误消息 这是我在过去几周使用这个包时从未遇到过的 我无法导入特定于道琼斯指数 DJI 的数据 我收到以下错误消息 getSymbols DJI src yahoo from
  • 列出 R 数据文件的内容而不加载

    我有时用print load myDataFile RData 当我加载数据文件时列出它的内容 有没有办法列出内容而不加载数据文件中包含的对象 我认为如果不加载对象就无法做到这一点 解决方案可能是使用包装器将 R 对象保存到save 该函数
  • R 闪亮仪表板中的动态重复条件面板

    我正在尝试创建一个动态条件面板 所以我的条件如下 在用户界面中输入 selectInput inpt Input Number seq 1 50 1 selectize FALSE 我的条件面板 UI 输入是 conditionalPane
  • 不同编程语言中的浮点数学

    我知道浮点数学充其量可能是丑陋的 但我想知道是否有人可以解释以下怪癖 在大多数编程语言中 我测试了 0 4 到 0 2 的加法会产生轻微的错误 而 0 4 0 1 0 1 则不会产生错误 两者计算不平等的原因是什么 在各自的编程语言中可以采
  • 实现 XGboost 自定义目标函数

    我正在尝试使用 XGboost 实现自定义目标函数 在 R 中 但我也使用 python 所以有关 python 的任何反馈也很好 我创建了一个返回梯度和粗麻布的函数 它工作正常 但是当我尝试运行 xgb train 时它不起作用 然后 我
  • 如何按用户定义(例如非字母顺序)对数据框进行排序[重复]

    这个问题在这里已经有答案了 给定一个数据框dna gt dna chrom start chr2 39482 chr1 203918 chr1 198282 chrX 7839028 chr17 3874 以下代码重新排序dna by ch

随机推荐