調查多一點它沒有經過似乎與assign()
和input[[paste0(i)]]
功能: ui.r:
library(shiny)
shinyUI(fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
selectInput("Filter1","Filter1",choices = c("A","B","C"),selected = "A"),
selectInput("Filter2","Filter2",choices = c("AB","BC","CD"),selected = "AB"),
selectInput("Filter3","Filter3",choices = c("ABC","BCD","CDF"),selected = "ABC"),
plotOutput("distPlot")
)
)
))
server.r:
library(shiny)
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
# generate bins based on input$bins from ui.R
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
#Filter1<-input$Filter1
#print(Filter1)
#print(input$Filter2)
for(i in c("Filter1","Filter2","Filter3")){
#Filter3 <- input[[paste0('Filter3')]]
assign(i,input[[paste0(i)]])
print(get(i))
}
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
})
這可能是微不足道的,但您使用的代碼下部區段一資「F」,並在代碼的較高塊較低的情況下,「F」。它是否說它找不到'filter1'? – giraffehere
謝謝,我很快就寫了第一個代碼塊,但它不會導致我的錯誤。我做了編輯。 –
你在哪裏需要'Filterx'?你可以通過調用'input [[paste0(Filter,x)]]'來調用'Filterx'嗎? –