Я пытаюсь создать блестящее приложение, в которое пользователь загружает данные во время выполнения. Когда я запускаю свое приложение Shiny, ниже открывается экран. Справа я хочу, чтобы он ничего не отображал до загрузки данных, но, как видите, в конце отображается предупреждение.
Я попытался поместить значение атрибута inherit.aes = False, поскольку ggplot использует столбец execute_date из данных, но это по-прежнему не работает.
Ниже мой код:
library(readxl)
library(shiny)
#install.packages("shinyWidgets")
library(shinyWidgets)
df <- read_xlsx("Results.xlsx", sheet = 1)
lst.measures <- as.list(unique(df$DQ_Check))
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Data Quality Result Monitoring Dashboard"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose xlsx file',
accept = c(".xlsx")
),
radioButtons("disp", "Display",
choices = c(Head = "head",
All = "all"),
selected = "head"),
pickerInput(
inputId = "myPicker",
label = "Which DQ Checks would you like to see in more detail?",
choices = lst.measures,
multiple = TRUE,
options = pickerOptions(
actionsBox = TRUE,
size = 10,
selectedTextFormat = 'count > 3'
)
)
),
# Show a plot of the generated distribution
mainPanel(
h4("Chart"),
plotOutput("linechart"),
h4("Observations"),
tableOutput("contents")
)
)
)
# Define server logic required to draw a histogram'
library(ggplot2)
library(tidyverse)
server <- function(input, output) {
df <- reactive({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
df <- read_xlsx(inFile$datapath, sheet = 1)
df
})
output$linechart <- renderPlot({
ggplot(df(),aes(x= Execution_Date,y=Fail_Count, group(Execution_Date)),inherit.aes = FALSE)+geom_bar(stat = "identity")
})
output$contents <- renderTable({
# input$file1 will be NULL initially. After the user selects
# and uploads a file, head of that data file by default,
# or all rows if selected, will be shown.
dataset <- df()
if(input$disp == "head") {
return(head(dataset))
}
else {
return(dataset)
}
})
}
# Run the application
shinyApp(ui = ui, server = server)