r - 发布闪亮应用程序时出现问题 - renderWidget(instance) 中的警告:忽略附加内容;appendContent 不能在 Shiny 渲染调用中使用
问题描述
尝试发布 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)
解决方案
推荐阅读
- python - python - 使用具有相同索引的另一个数据框替换数据框中的值
- python - 计算字符串中的公式
- java - Java 11 HttpClient 间歇性挂起
- unix - 数据阶段挑战
- powershell - Powershell 不会使用 nssm 启动或停止 Windows 服务
- azure-api-management - API 管理 - 为每个操作创建相同的策略
- javascript - 根据jQuery中的函数参数显示某些列表
- linux - 在变量中使用星号作为 bash 中的扩展名
- python - Django/mod_wsgi/Apache - mod_wsgi 没有使用为其编译的 Python 版本 - “ModuleNotFoundError: No module named 'math'”
- mongodb - MongoDB/Mongoose:名称匹配时使用 $sum 计算数量