Hey there,
it might be useful if you could provide an exemple dataset with the first 5 rows or so and a reprex (minimal exemple to reproduce the problem) exemple of your App code. The above seems to be missing some parenthesese.
Plus, I am not sure as to what you are trying to achieve exactly as your code does not detail any output elements.
Do you want to display the data to the user as a table or plot?
Do you want to use the input dataset to compute calculations?
However, based on what you wrote I tried to approximate a solution. Does this help?
library(shiny)
ui <- fluidPage(
selectInput("cropId", "Crop Type",
c("Corn [bu/ac]" = "corn",
"Potato [cwt/ac]" = "pota")),
# Select the county
selectInput("County", label = "County", choices = c("County 1", "County 2", "County 3"),
selected = NULL, multiple = FALSE),
tableOutput("Crop_data")
)
server <- function(input, output, session) {
NASS_Corn_data <- data.frame(Var1 = rnorm(5),
Var2 = c("This", "is", "corn", "information", "!"))
NASS_Potato_data <- data.frame(Var1 = rnorm(5),
Var2 = c("This", "is", "potato", "information", "!"))
# This returns the correct dataset
datasetInput <- reactive({
if (input$cropId == "corn"){
dataset <- NASS_Corn_data
}
else if (input$cropId == "pota"){
dataset <- NASS_Potato_data
}
return(dataset)
})
#This shows you the correct dataset
output$Crop_data <- renderTable ({
datasetInput()
})
}
shinyApp(ui = ui, server = server)