Print Proverb at R Startup

Sometimes it’s necessary to force oneself to do the thing that one should do. One way to do this is to have proverbs print the day’s proverb to console any time you start or restart R in RStudio.

We can do that by modifying our .Rprofile file. For our purposes, we will modify the version that affects your base user environment.

There is a handy function is the {usethis} package that helps us edit our .Rprofile:

library(proverbs)
library(usethis)
usethis::edit_r_profile(scope = "user")

This will open up our .Rprofile file, and and we have to do is throw in our function from {proverbs} to make it spit out a proverb at startup:

if(interactive()) {

proverbs::proverb()

}

You’ll need to restart your session but you should be greeted with a proverb after that.

If you want to customize the color of the printed output to sing more closely with your theme, for example, we can do that.

if(interactive()) {

proverbs::proverb(main_color = "black", accent_color = "silver")

}

This will print your proverb in black text with silver (grey) highlights.

mirror server hosted at Truenetwork, Russian Federation.