Is there a way to output text to the R console in color

偶尔善良 提交于 2019-11-26 20:48:07

问题


I am writing a script and I want to output text messages to the console with different colors depending on conditions. For example: RED for errors and BLUE for warnings, etc.

I am using RStudio.


回答1:


Check out the new crayon package:

library(crayon)
cat(blue("Hello", "world!\n"))

More info on the GitHub page.

Works in RStudio 1.2.360+




回答2:


The xterm256 package by Romain Francoise allows this sort of thing in general on any console that understands xterm256 interrupts.



来源:https://stackoverflow.com/questions/10802806/is-there-a-way-to-output-text-to-the-r-console-in-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!