闪亮的browser(),if语句

时间:2018-11-12 22:12:56

标签: if-statement browser shiny

我正在创建一个Shiny应用程序,当我使用browser()函数进行调试时,if语句出现错误

例如,如果我写这个(下面是完整的示例):

if(1 < 2) 
 {
      h <- 5
 }

我收到以下消息: 在#3调试:h <-5

可能是什么问题?看起来if语句在浏览器中不起作用。 谢谢

library(shiny)


# Global variables can go here
n <- 200


# Define the UI
ui <- bootstrapPage(
  numericInput('n', 'Number of obs', n),
  plotOutput('plot')
)


# Define the server code
server <- function(input, output) {

  browser()
  if(1 < 2) 
  {
    h <- 5
  }

  output$plot <- renderPlot({
    hist(runif(input$n))
  })
}

# Return a Shiny app object
shinyApp(ui = ui, server = server)

0 个答案:

没有答案