Я знаю, что это звучит немного базово c, но я хотел бы создать интерактивный барплот, который может обрабатывать несколько осей х и у, независимо от того, захочет ли его использовать пользователь.
Я начал это так таким образом, однако я знаю, что есть много вещей, которые необходимо добавить.
library(dplyr)
library(shiny)
library(ggplot2)
# Sample workable data
sample <- data.frame("Country" = c("Australia", "Bangladesh",
"Argentina", "Slovakia", "Greece", "Sweden"),
"Attribute1" = 57:62,
"Attribute2" = 13:18,
"Attribute3" = 5:10)
# Since I cannot enter the choices one by one..
Atts <- sample %>%
select(Attribute1:Attribute3) %>%
names()
Ctrs <- unique(sample$Country)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Sample Drop Down"),
# Sidebar with dropdown
sidebarLayout(
sidebarPanel(
selectInput(inputId = "selects", choices = Ctrs,
label = "Select Region", multiple = TRUE),
selectInput(inputId = "selects2", choices = Atts, label = "select attribute",
multiple = TRUE)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("Plot")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$Plot <- renderPlot({
ggplot(data = sample, aes(x = input$selects, y= input$selects2)) +
geom_bar(stat = "identity", color = "blue", fill = "Country")
})
}
# Run the application
shinyApp(ui = ui, server = server)
Так как мне связать пользовательский интерфейс и серверную часть вместе?