Displaying R Version on Launch

I’ve started using rig to manage my R versions, since I need both current and development versions. I wanted a way to keep track of which version of R was currently running. I started with a simple cat call in my .Rprofile, but that caused issues occasionally.

Instead, one solution is to use message(). E.g.,

message(paste0("Version: ", version$major, ".",
               version$minor, " ", version$status))

Note that this is not affected by the --quiet flag, so R --quiet will suppress the long R startup message while still displaying your custom message.

(I also played around with modifying the prompt but decided against it, but if that’s your flavor, check this stackoverflow answer for how to manipulate it.)

Home | Back to blog

This work is licensed under CC BY-NC 4.0 Creative Commons BY-NC image