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.
In RStudio under tools -> Options -> Appearance you can change the color of your R console and also change the fonts.
You can also save the entire R console screen within the GUI by clicking on "Save to File..." under the menu "File." This saves the commands and the output to a text file, exactly as you see them on the screen.
Every language provides some functions that can help you print the data on the console, and R is no different. To print the data on the console in R, use the print() function.
I just found a solution that works at least on my present OS, Linux Mint (19.3): Just select text and click with middle mouse button to the place (e.g. in WPS Office or LibreOffice) where you want to copy-paste the selected text. It will instantly copy and paste the text without formatting.
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+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With