0
다른 입력으로 필터링 된 부분 집합을 기반으로 선택한 변수의 막대 그래프를 그리는 간단한 응용 프로그램을 작성하려고합니다. dataX$mpg
을 반환해야하는 라인 hist(dataX()$datasetInput())
에서 오류가 발생합니다. 어떻게 해결할 수 있습니까? 전체 코드 :비 기능을 적용하려고했습니다.
library(shiny)
u <- shinyUI(pageWithSidebar(
headerPanel("Staz w bezrobociu"),
sidebarPanel(
selectInput("variable", "Variable:",
list("Milles/gallon",
"Horse power")
),
textInput("nc","Number of cylinders",value = 6)
),
mainPanel(
plotOutput("Plot")
)
))
s <- shinyServer(function(input, output)
{
dataX <- reactive({mtcars[mtcars$cyl==input$nc,,drop = FALSE]})
datasetInput <- reactive({
switch(input$variable,
"Milles/gallon" = mpg,
"Horse power" = hp)
})
output$Plot <- renderPlot({
hist(dataX()$datasetInput())
})
})
shinyApp(u,s)