I'm working with R, in RStudio, and I use to specify the package of each function in my scripts, even if the package is already loaded in the environment. I want to be sure that the code will use the filter()
function from dplyr, and not from another package which has a similar named function.
For instance :
Question/ to make code easier to read, is there a way to play with global appearance colors, and that package names (all names before ::
) are in a different color (light grey for instance) ?
Here is a complete answer, I guess will work.
Since a recent version of rstudio, you can add custom themes on rstudio (see this update blog)
From this point you can create custom themes, but it require you to know the "code" for each part of your script. After opening the inspector, I've foudn that the dplyr
word before the ::
is named as support
. See the color used in the theme Cobalt here (custom theme editor).
Finally, once you created your own theme by modification of a previous one (creating from scratch is always a pain), you import it in rstudio (see in the first link) and apply it.
At this point you won't see any change, because you also need to check Global options > Code > Diplay > highlight R function call. This will highlight the word classified as support
and as support.function
. You can set both colors in the theme editor (Cobalt theme has the first one in light green and the second one in light orange).
I've not done the full process myself but I think it could work.