Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

r - Rshiny did not show any hint in the console so how to debug the Rshiny code?

I found the rshiny script is super hard to debug. Especially, the rshiny bottom is the RunAPP. If I get the error. I did not see any hints from the Console. Could I ask how you guys debug the rshiny?

Thanks

question from:https://stackoverflow.com/questions/65893233/rshiny-did-not-show-any-hint-in-the-console-so-how-to-debug-the-rshiny-code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Most of all: always keep in mind that you need to test and debug your code. Do not just write code to satisfy requirements. Consider testing and debugging to be a requirement itself. That mind set is a good starting point to follow these rules:

  1. R-Studio provides quite some functionality useful for debugging: step-by-step execution of your code, a trace of function calls, inspection of variables, and the opportunity to run your own code on the console while the app is on hold.
  2. If breakpoints do not work (sometimes they just won't), add browser() to your code which creates a "forced" breakpoint.
  3. Sometimes print() helps getting additional information output to the console.
  4. Clearly separate the business logic from the UI. Use unit tests (testthat). If errors occur, write some sample code to test the business logic outside the shiny app.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...