Reputation: 3280
I want to output a partially colored string. e.g. something like:
print(paste("This is how", style("Red","red", "bold"), "looks."))
[1] "This is how Red looks."
The string Red should be colored in red.
Any help will be much appreciated!!
Upvotes: 4
Views: 6706
Reputation: 11413
Perhaps the crayon
package can help you:
library(crayon)
cat("This is how", red("Red"), "looks.\n")
Output:
If you want more features, perhaps the xterm256 package will be helpful.
Upvotes: 0
Reputation: 121608
You can hack it using text
:
plot(1:10,1:10,type='n',frame.plot=F,axes=F,xlab="",ylab="")
text(5,1,"This is how")
text(5.8,1,"Red",col='red',font=2)
text(6.3,1,"looks.")
Upvotes: 1