Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - How to output a partially colored string in R?

Tags:

r

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!!

like image 938
Shambho Avatar asked Dec 05 '25 09:12

Shambho


1 Answers

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.")

enter image description here

like image 128
agstudy Avatar answered Dec 08 '25 00:12

agstudy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!