我已构建此仪表板,在本地显示时可以正常工作,但在我尝试将其部署到shinyapps.io时无法打开。根据我的故障排除,我已经指定了wd,并确保所有文件都在目录中,但没有取得任何成功。当我尝试在shinyapp.io中启动仪表板时,我收到以下消息:Error: an error has occured. Check your logs or contact the app author for clarification
内存使用量不超过120 MB,因此我不认为这是问题的根源。任何帮助将不胜感激。我还想知道是否有可能有一个名称基于所选位置值的选择框,类似于在您选择了自己的国家后有一个状态下拉框的常见情况。
library(shiny)
library(shinydashboard)
library(ggplot2)
library(rsconnect)
library(lubridate)
library(scales)
library(plyr)
library(dplyr)
library(RColorBrewer)
```
```{r}
AdjustedData<- read.csv("Adjusted Data.csv")
Target <- data.frame(yintercept= 40.00, Target= factor(40.00))
AdjustedData$Percentage <- round(AdjustedData$Total.Procedure/AdjustedData$Reconciled.Visits*100, 2)
AdjustedData$Percentage[is.na(AdjustedData$Percentage)] <- 0
opt <- read.csv("optimization.csv")
opt$OptPer <- opt$Optimization*100
opt$Location <- as.character(opt$Location)
opt$Location <- ifelse(opt$Location == "New Jersey" | opt$Location == "Indiana" | opt$Location == "Pennsylvania", "New Jersey/Indiana/Pennsylvania", opt$Location)
opt$Location <- as.factor(opt$Location)
ui <- dashboardPage(
dashboardHeader(title = "Performance Metrics"),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(title = "Options",
selectInput(inputId = "Month",
label = "Month:",
choices = c("January" = "1", "February" = "2", "March" = "3")),
selectInput(inputId = "Location",
label = "Location:",
choices = c("Illinois", "Wound MD", "Ohio", "New York")), width = 1000, height = 200),
box(plotOutput("barplot", height = 500, width= 800)),
box(plotOutput("barplot2", height= 500, width = 800)),
box(plotOutput("barplot3", height = 500, width = 800))
)))
server <- function(input, output) {
data <- reactive({
dataset <- subset(AdjustedData, Location == input$Location & Reconciled.Month == input$Month)
})
data2 <- reactive({
dataset2 <- subset(opt, Location == input$Location & Month == input$Month)
})
data3<- reactive({
dataset3 <- subset(data, )
})
output$barplot <-renderPlot({
ggplot(data= data(), aes_string(x="Provider",y= "Per.Visit.Bill.Rate", fill = "Per.Visit.Bill.Rate")) +
geom_bar(stat="identity")+
labs(caption = "Data sourced from Provider Compensation Analysis and Monthly Summary \nof Billed Physician Encounters Reports. Rates have been adjusted to exclude \nthe deduction per visit for malpractice insurance where applicable.")+
theme_light()+
theme(plot.caption = element_text(size= 8, hjust = .5))+
theme(axis.text.x=element_text(angle= 45, vjust=.5)) +
ggtitle("Per Visit Bill Rate", input$Location)+
theme(plot.title = element_text(size = 22, hjust = .5, family = "serif"))+
theme(plot.subtitle = element_text(size = 18, hjust = .5, family = "serif"))+
geom_text(aes(label=sprintf("$%.2f",Per.Visit.Bill.Rate)), position=position_dodge(width=0.9),hjust= .5, vjust=0,angle= 0) +
scale_y_continuous(name = "Per Visit Bill Rate ($)", limits = c(0,100),breaks =seq(0,100,10), labels = dollar)+
scale_color_continuous()+
geom_hline(aes(yintercept = yintercept , linetype = Target), data = Target, color = "red", size = 1.0)+
guides(fill=guide_legend(title = "Per Visit Bill Rate ($)", reverse = TRUE))+
theme(plot.title = element_text(hjust = 0.5))
})
output$barplot2 <-renderPlot({
ggplot(data= data(), aes_string(x="Provider",y= "Percentage", fill= "Per.Visit.Bill.Rate")) +
geom_bar(stat = "identity")+
geom_text(aes(x=Provider, y= Percentage, label=sprintf("%.1f%%", Percentage)), position=position_dodge(width=0.9),hjust= .5, vjust= 0 ,angle= 0)+
labs(caption = "Data sourced from Provider Compensation Analysis and \nMonthly Summary of Billed Physician Encounters Reports, March 2018 \nRates have been calculated using the sum of all procedure codes.")+
scale_y_continuous(name = "Percentage (%)", limits = c(0,100),breaks =seq(0,100,10))+
scale_color_continuous()+
theme(plot.caption = element_text(size= 8, hjust = .5))+
theme(axis.text.x=element_text(angle= 0, vjust=.5))+
ggtitle("Procedure Percentages", input$Location)+
theme(plot.title = element_text(size = 22, hjust = .5, family = "serif"))+
theme(plot.subtitle = element_text(size = 18, hjust = .5, family = "serif"))+
guides(fill=guide_legend(title = "Month", reverse =FALSE))
})
output$barplot3 <- renderPlot({
ggplot(data= data2(), aes_string(x = "Provider", y= "OptPer", fill= "OptPer"))+
geom_bar(stat = "identity") +
geom_text(aes(x= Provider, y= OptPer, label=sprintf("%.1f%%", OptPer)), position = position_dodge(width=.6), hjust= .5, vjust=0)+
theme_light()+
theme(axis.text.x=element_text(angle= 45, vjust=.5))+
scale_color_continuous()+
ggtitle("Optimization Percentages", input$Location)+
labs(caption = "Data sourced from Provider Compensation Analysis Reports, March 2018")+
theme(plot.caption = element_text(size= 8, hjust = .5))+
ylab("Optimization Percentage")+
theme(plot.title = element_text(size = 22, hjust = .5, family = "serif"))+
theme(plot.subtitle = element_text(size = 18, hjust = .5, family = "serif"))+
scale_y_continuous(limits= c(0,100), labels = function(x) paste0(x, "%")) +
guides(fill=guide_legend(title = "Optimization Percentage (%)", reverse = TRUE))
})
}
shinyApp(ui, server)
deployApp("DashboardApp.Rmd")
数据集:示例
Provider Reconciled Month Per Visit Bill Rate- w/Mal Per Visit Bill Rate Location
Andrews 1 27.68 30.57 Illinois
Davids 2 25.08 29.08 New York
Stein 3 31.39 31.39 New York
Goodman 2 26.00 30.00 Wyoming
Roberts 3 24.34 25.74 Utah
Buckley 1 29.54 33.54 Ohio
Castro 3 0.00 0.00 Ohio
答案 0 :(得分:0)
您是否有任何特殊原因要在Rmd上托管仪表板?如果您必须坚持使用该格式,请确保您没有在包含Shiny应用程序的目录中部署Rmd文件。您可以查看此documentation了解详情。