我正在尝试调试我的闪亮应用程序,并希望查看反应式数据框,例如一瞥(df)。
最初,我尝试创建一个断点,然后通过我的反应式 df 在 server.r 中使用时查看环境是一个值而不是对象。我也尝试过browser()
但不确定它会做什么。
我对SO做了一些搜索,并使用sink()、renderPrint()尝试了各种方法,但没有成功。
如何打印内容glimpse(some_reactive_df())
当我运行我的应用程序时到控制台?
Calling print()
从内部reactive({})
表达会做到这一点。
library(shiny)
library(dplyr)
shinyApp(
ui <- fluidPage(
selectizeInput("cyl_select", "Choose ya mtcars$cyl ", choices = unique(mtcars$cyl)),
tableOutput("checker") # a needed output in ui.R, doesn't have to be table
),
server <- function(input, output) {
d <- reactive({
d <- dplyr::filter(mtcars, cyl %in% input$cyl_select)
print(glimpse(d)) # print from within
return(d)
})
output$checker <- renderTable({
glimpse(d()) # something that relies on the reactive, same thing here for simplicty
})
})
假设您为 Shiny 提供了运行(并重新运行)您感兴趣的反应性的理由,让其参与渲染server()
和链接输出ui()
。这通常是我的调试场景的情况,但除非反应在其他地方使用,否则它不会工作app.R
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)