Hi! I am planning to create an app which allows a user to import a xlsx file within the ui which in turn will be manipulated by a function I established outside of the server (xlsx file is exported from another software and always has the same structure/header names etc.). This manipulated and summarized data I would like to plot with ggplot2. I don't know if it's even possible since I am relatively new to shiny.
Here is the code I am working with so far.
ui <- fluidPage(
titlePanel("data analysis"),
sidebarLayout(
sidebarPanel(
fileInput("upload",label="data",buttonLabel="Upload...",multiple=F,
placeholder="No file selected",accept=".xlsx"),
selectInput("parameter",
"select parameter for plotting",
selected="parameter 1",
choices=c("parameter 1","parameter 2",
"parameter 3","parameter 4")),
actionButton("trigger","Run Analysis",icon=icon("play"))
),
mainPanel(
plotOutput("plot")
)
)
)
server <- function(input,output,session){
data <- reactive({
req(input$upload)
inFile <- input$upload
read_excel(inFile$datapath,1)
})
manipulated <- reactive(input$upload,data.frame(analysis(data())))
output$plot <- eventReactive(input$run_button,renderPlot({
ggplot(manipulated(),aes(x=timepoint_description,y=get(input$parameter),group=treatment))+
geom_point(aes(color=treatment),size=3)+
geom_line()+
geom_errorbar(aes(ymin=get(input$parameter)-get(paste(input$parameter,"_sd",sep="")),
ymax=get(input$parameter)+get(paste(input$parameter,"_sd",sep=""))),width=0.3)+
labs(x="time",y=paste("average",input$parameter))+
theme_classic()
})
}
Looking forward to you help