我是闪亮的新手,并根据this question
的答案构建应用但是代码中有一节我不明白,并且无法在闪亮的文档中找到更多的洞察力。 在下面的代码部分(the example的一部分),为什么要使用本地?和ii< - i赋值?
如果这不是一个正确的stackoverflow问题我很抱歉!这是我的第一个..
renderPlots <- function(n, input, output, prefix="plot") {
for (i in seq.int(n)) {
local({
ii <- i # need i evaluated here
## These would be your 10 plots instead
output[[sprintf('%s_%g', prefix, ii)]] <- renderPlot({
ggplot(dat, aes_string(x='time', y=input$var)) + rndmPlot(input)
})
})
}
}