有什么方法可以在 VS Code 中调试 Shiny (R) 吗?我可以在 RStudio 中轻松调试 Shiny 应用程序,但我喜欢在 VS Code 中编写代码,因此寻找在 VS Code 中调试 R 代码的方法。
看来,shiny 可以在 VSCode 中使用
browser
语句进行调试 🙌
先决条件
appDir
时请参阅 ?shiny::runApp
的文档了解可能的设置)调试
browser()
设置断点(RStudio 文章)shiny::runApp()
更多资源
在调试模式下我无法看到绘图或 html(例如从绘图中)。我已经启用了“httpgd”作为绘图设备。该选项表示它还会更改相应的 R 选项
vsc.use_httpgd
,但我检查过它是NULL
。在我的 .Rprofile
中或在调试会话中明确设置它允许我再次看到绘图,例如通过print(plot(1:5))
。
# For your .Rprofile
options("vsc.use_httpgd" = TRUE)
# code to check if option is set
getOption("vsc.use_httpgd")