代码
代码从第39行开始,xaj.model(params)$floodNumber
返回的是一个list
:
> xaj.model(params)$floodNumber[1] # 示例名
$`870513`
# A tibble: 11 x 6
date p q1 q2 r1 r2
<date> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1987-05-10 2.8 20.3 1.82 0.0244 0.0247
2 1987-05-11 23.9 20.2 3.46 0.0463 1.86
3 1987-05-12 0.9 31.7 21.1 0.283 0.0135
4 1987-05-13 0 160 11.5 0.155 0
5 1987-05-14 0 103 9.37 0.126 0
6 1987-05-15 0.4 70.3 8.22 0.110 0
7 1987-05-16 0 55.9 7.42 0.0994 0
8 1987-05-17 0.3 39.9 6.74 0.0903 0
9 1987-05-18 0 33.6 6.18 0.0828 0
10 1987-05-19 0.3 29.4 5.67 0.0760 0
11 1987-05-20 14.7 26 6.19 0.0829 1.07
floodNumber <- reactive({
params <- c(input$WM, input$WUM, input$WLM, input$K, input$C, input$B, input$SM,
input$EX, input$KG, input$KSS, input$KKG, input$KKSS, input$FE)
number <- which(names(xaj.model(params)$floodNumber) == input$inselect)
(xaj.model(params)$floodNumber)[number][[1]] %>%
str()
})
output$fn <- renderPrint({
floodNumber()
})
报错
代码[number]
引用方式我在 console 中试过没问题,%>%
就更别说了,可是这里还是报了错。
Warning: Error in [[: subscript out of bounds
119: eval
118: eval
117: %>%
116: <reactive:floodNumber> [E:\1WHU\junior2\xaj/server.R#45]
100: floodNumber
99: renderPrint [E:\1WHU\junior2\xaj/server.R#50]
98: func
82: origRenderFunc
81: output$fn
1: runApp
问题
虽然 shiny 生成出来了 App 而且这一段代码生成的结果也在 App 中能正常显示,但是还是不很明白为什么会报错,而且在另外的代码中我使用了dplyr::select()
函数也报告了 select 的问题,在代码首行已经有加载相关包。
补充:verbatimTextOutput("fn")
、tableOutput("fn")
报错但都能显示。
求助!