Я хотел бы иметь гистограмму в R / Shiny, есть динамика. Я выбираю страну и хотел бы видеть только данные по этой стране. Я создал часть кода R, но связь между выбором страны и гистограммой отсутствует.
server.R file
library(datasets)
salg <- read_excel("C:\\Users\\Tue Hellstern\\Documents\\Demo\\Demo\\data\\SalgsData.xlsx", sheet = "salgs_data")
# Define a server for the Shiny app
function(input, output) {
output$selected_var <- renderText({
paste("You have selected", input$valgtLand)
})
# Fill in the spot we created for a plot
output$salgplot <- renderPlot({
# Render a barplot
salg %>%
ggplot(aes(x=CompanyType, y=Total)) +
geom_bar(stat="identity")
})
}
Файл ui.R
library(datasets)
salg <- read_excel("C:\\Users\\Tue Hellstern\\Documents\\Demo\\Demo\\data\\SalgsData.xlsx", sheet = "salgs_data")
# Use a fluid Bootstrap layout
fluidPage(
# Give the page a title
titlePanel("Salg efter kundetype"),
# Generate a row with a sidebar
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(helpText("Du har mulighed for at vaelge kun at se et bestemt land"),
selectInput("valgtland", h3("Vaelg land"),
choices = salg$Country,
selected = 1)),
# Create a spot for the barplot
mainPanel(
plotOutput("salgplot")
)
)
)
Я получаю этот макет, но как мне сделать отношение выделения / линейного графика?
введите описание изображения здесь