First time using Shiny app (still new with using R), so will appreciate simple explanations. I’ve manged to piece codes from various templates to achieve what I’d ideally like which is an app that allows users to upload a csv file and click a button that will display the graph to the right. The graph will use the date column and metric column from the uploaded data to display a spc chart using the package NHSRPlotthedot
The below is what I’m using to create the app:
ui <- fluidPage(
titlePanel("plot"),
sidebarLayout(
sidebarPanel("Sidebar panel",
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE),
actionButton('click', 'Chart')
),
mainPanel("Plot",
plotOutput("MyChart"),
tableOutput("table.output")
)
)
)
server = function(input, output, session) {
a <- reactive({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
tbl <- read.csv(inFile$datapath, header=input$header) #, sep=input$sep, dec = input$dec)
return(tbl)
})
output$table.output
shinyApp(ui, server)
However I’m not sure how to add the graph to the server.R part of the code.
Ideally I’d like to use the uploaded data to feed the below code:
MyInputData%>% ptd_spc(value_field =metric, date_field = date, improvement_direction = "decrease")
And display the graph on the right side of my app.