Where am I making the mistake? And what is causing this error? Thanks.
Here is the full error message:
Listening on http://127.0.0.1:7891
Warning: Error in : You're passing a function as global data.
Have you misspelled the data argument in ggplot()
library(shiny)
library(dplyr)
library(ggplot2)
COV <- read.csv('pathway', stringsAsFactors = F)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("selectInput1",
"Select PID:",choices = unique(COV$PID),
selected = "1000"),
selectInput("selectInput2",
"Select Parent Identifier",
choices = unique(COV$M_CM),
selected = "1"),
selectInput("selectInput3",
"Select x variable:",
choices = names(COV),
selected = "StartDate"),
selectInput("selectInput4",
"Select y variable:",
choices = names(COV),
selected = "COV_WOR")
),
mainPanel(
plotOutput('plot')
)
)
)
server <- function(input,output){
selectedData <- reactive({
COV[COV$PID == input$selectInput1 & COV$M_CM == input$selectInput2, c(input$selectInput3, input$selectInput4)]
})
output$plot <- renderPlot({
# Use aes_string for column names stored in strings
p <- ggplot(selectedData, aes_string(x = input$selectInput3, y = input$selectInput4))+
geom_line()
p
})
}
shinyApp(ui,server)