我试图根据selectInput中的选择显示直方图。输出应该是hist(dataframe $ feature1),具体取决于他们选择的功能,但没有显示任何内容。这是我的代码。
ui.R
selectInput("variableFeat", "Choose Feature", c("feature1", "feature2", "feature3"))
server.R
output$feature <- reactive({
dataframe$input$variableFeat
})
output$hist <- renderPlot({
hist(feature(), main="Histogram of Selected Feature", xlab="Selected Feature", ylab="Frequency", col="orange")
})
答案 0 :(得分:0)
要渲染直方图,首先根据用户输入创建值向量,然后使用if语句选择要查看的要素:
server.R
output$hist <- renderPlot({
vectorOfValues1 <- dataFrame$FEATUREtoPLOT1
vectorOfValues2 <- dataFrame$FEATUREtoPLOT2
if (input$variableFeat == "Choice1") {
hist(vectorOfValues1}
}
if (input$variableFeat == "Choice2") {
hist(vectorOfValues2}
}}
})
ui.R
outputPlot("hist")