问题描述
编辑:这显然与系统有关,因为三个评论者已经证明我的代码有效。
如何确定需要在服务器中进行哪些更改才能使其正常工作?
我已经发布了完整的 csv,以消除可能没有出现在日志中的任何代码页错误。 Rutte2.csv Rutte3.csv
schoutencc@vps-01-minfin:/var/www/shiny-server$ sudo cat /var/log/shiny-server/test-shiny-20210716-192927-36317.log
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter,lag
The following objects are masked from ‘package:base’:
intersect,setdiff,setequal,union
Loading required package: ggplot2
Attaching package: ‘plotly’
The following object is masked from ‘package:ggplot2’:
last_plot
The following object is masked from ‘package:stats’:
filter
The following object is masked from ‘package:graphics’:
layout
Listening on http://127.0.0.1:36317
schoutencc@vps-01-minfin:/var/www/shiny-server$
一定是微不足道的东西,但我显然看不到它。我正在尝试使用带有 plotly 库的 R/shiny 将一些数据可视化为甜甜圈。数据来自三个 csv(其中两个合并,第三个将用于稍后在段之间画线)。
在调试期间,我的输出中还有一个普通数据表,因此我可以看到数据被正确读取。该表是根据我的预期填充的,因此它的数据端似乎运行正常。
然后添加甜甜圈 - 现在只需具有相同大小的部分,每章一个。不能使最小示例比这更简单。在稍后的阶段,我将使用段大小、连接段的线等。
唉,我的代码完全没有渲染。好吧,它确实在数据表上方的网页上呈现了一个空白区域,这对我来说意味着代码执行时没有错误,但由于某种原因它没有填充。
日志中没有出现错误。
当前代码:
library(shiny)
library(dplyr)
library(plotly)
ui <- fluidPage(
plotlyOutput("plot"),dataTableOutput("rawdata")
)
server <- function(input,output,session) {
# Read two csv's containing columns named chapter,article etc.
dtRutte2 <- read.csv("Begroting.Rutte2.csv",sep=';',fileEncoding="Windows-1252")
dtRutte3 <- read.csv("Begroting.Rutte3.csv",fileEncoding="Windows-1252")
# Merge these two csv's into one and filter out duplicates
dtBegroting <- rbind(dtRutte2,dtRutte3) %>% group_by(Begrotingshoofdstuk,Artikelnummer) %>% mutate(rn=row_number()) %>% filter(rn==1) %>% ungroup()
# Not used yet,will populate a number of internally connecting lines
dtHerverkavelingen <- read.csv("Herverkavelingen.Rutte3.csv")
# For debugging purposes: show plain data
output$rawdata <- renderDataTable(dtBegroting)
# Construct a pie/donut chart using field 'Chapter name' as label and field 'rn' (see above,always 1) as value to ensure visually uniform distribution add a locale to avoid errors in gsub saying input string is invalid in this locale
pie <- dtBegroting %>% plot_ly(labels=~Begrotingsnaam,values=~rn,type='pie',textinfo='label',insidetextorientation='radial')
pie <- pie %>% layout(title='Begrotingshoofdstukken',xaxis=list(showgrid=FALSE,zeroline=FALSE,showticklabels=FALSE),yaxis=list(showgrid=FALSE,showticklabels=FALSE))
pie <- pie %>% add_pie(hole=0.6)
pie <- pie %>% config(locale='nl')
output$plot <- renderPlotly(pie)
}
shinyApp(ui,server)
来自 csv 的样本(布局相同的文件,只是年份不同):
Begrotingsjaar;Begrotingshoofdstuk;Begrotingsnaam;Artikelnummer;Artikelnaam
2019;B;Gemeentefonds;2;Onderzoek
2019;B;Gemeentefonds;3;Programma
2019;B;Gemeentefonds;4;Integratie-uitkering sociaal domein
2019;C;Provinciefonds;1;Provinciefonds
2019;F;Diergezondheidsfonds;1;Bewaking en bestrijding van dierziekten
2019;H;BES-fonds;1;BES-fonds
2019;I;De Koning;1;Grondwettelijke uitkering aan de leden vh Koninklijk Huis
2019;I;De Koning;2;Functionele uitgaven van de Koning
2019;I;De Koning;3;Doorbelaste uitgaven van andere begrotingen
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)