0

I am developing a shiny app and frequently use the dput(names(data)) in the renderUI. Because of it, I see the output of dput(names(data)) on the console.

How to prevent dput showing the output in the console?

Thank you.

D

JohnS
  • 41
  • 1
  • 1
    Either comment it out or use something like `logger::log_debug` where your normal logging threshold is above (less-terse than) `logger::DEBUG`. By selective use of `logger::log_threshold`, you can allow or prevent its printing on the console regardless of in-`shiny` or out. – r2evans Nov 12 '19 at 04:11
  • Thanks for the reply! It is not clear how can I do that. Trying ```logger::log_debug(dput(names(data)))``` did not solve the issue. – JohnS Nov 12 '19 at 04:30
  • 1
    Try this: when "playing", use `logger::log_threshold(logger::DEBUG)`. But in "production" (i.e., when you do not want to see the output from `dput`), use `logger::log_threshold(logger::INFO)`. – r2evans Nov 12 '19 at 04:37
  • I apologize, but I am not able to get it right. I followed your advice, but yet I see the output of ```dput()``` on the console. To clarify, I am developing a ```shinydashboard```. – JohnS Nov 12 '19 at 04:45
  • If you set `log_threshold(INFO)` then anything logged with `log_debug` will be silent/unobserved. If you still see it, then you are doing something else wrong. This question is nearly impossible to help much further without details. If you need more help, please read how to provide a good reproducible question: https://stackoverflow.com/questions/5963269, https://stackoverflow.com/help/mcve, and https://stackoverflow.com/tags/r/info. – r2evans Nov 12 '19 at 06:11
  • Not sure what you want. What about `capture.output(dput(names(data))`? – Stéphane Laurent Nov 12 '19 at 13:12
  • @StéphaneLaurent ```capture.output()``` suppresses the output in the console, but then have an issue with ```selectizeInput``` which shows in the drop-down menu ```c("var1","var2)``` instead of ```var1```, ```var2```. – JohnS Nov 12 '19 at 13:18
  • @JohnS Please provide some code. We dont' know what you're doing and we have to guess. What about `toString(names(data))`? If that does not work, please provide a minimal reproducible example and explain what you want exactly. – Stéphane Laurent Nov 12 '19 at 13:21
  • @StéphaneLaurent thanks! Yes, I have to make a small reproduce example. Sorry for the inconvenience. ```toString()``` and ```capture.output()``` does not solve the issue. – JohnS Nov 12 '19 at 13:39

0 Answers0