Colourizing Code - "R For Data Science"dry

Hi everyone, I am new to the community so please feel free to correct me if I am not posting properly.

My question pertains to how I can colourize my code in a similar fashion to how the authors of "R For Data Science" do in their work. An example can be found Here. I am hoping to try and mimic the code found in the book both for ease of reading, my own preference for that particular aesthetic, and for future work when I begin to learn simulations and performing econometric analysis. Currently, I am familiar with how to change the appearance of the code via the pathway Tools -> Global Options -> Appearence, but the issue I am having is that I cannot seem to find any themes that mimic that of the text. I took a screencapture of what I have now, and as you can see, the main block text is one colour while the parenthesis, for example, are slightly different. I can imagine that as code grows more complicated, this would make it somewhat difficult to read.

TL;DR --> How do I get my code to look like the code found in the "R for Data Science" book?

Welcome to the community!

I'm not sure whether this answers your question or not, but you can try to do these:

  1. Go to Tool -> Global options -> Code -> Display.
  2. Turn on Show syntax highlighting in console input and Highlight R function calls.

Also, you can try to use a theme of your own. Take a look here.

2 Likes

Thank you for your response! What you recommended did exactly what I needed. In my earlier searches I would have thought that just using a theme would do what was necessary but that extra step in the code section is what was not obvious to me.

1 Like

Thank you for letting me know about this. I marked yours as the solution.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.