How to set the color palette in the .Rprofile

294 views Asked by At

I'd like to change the Color palette on startup of R. Thus I copied the following source-code to my .Rprofile

palette(c(
  "#2e3436"   # (Aluminium 6)
  , "#ef2929" # (Scarlet Red 1)
  , "#73d216" # (Chameleon 2)
  , "#3465a4" # (Sky Blue 2)
  , "#fcaf3e" # (Orange 1)
  , "#ad7fa8" # (Plum 1)
  , "#babdb6" # (Butter 1)
  , "#babdb6" # (Aluminium 3)
))

On startup of R the following message shows up:

Error: Could not fine the function 'palette'

Is it not possible to change the palette on startup?

1

There are 1 answers

0
Josh O'Brien On BEST ANSWER

From ?Startup

Note that when the site and user profile files are sourced only the 'base' package is loaded, so objects in other packages need to be referred to by e.g. 'utils::dump.frames' or after explicitly loading the package concerned.

So instead of palette(), call grDevices::palette(). (The call to dev.off() is needed to eliminate the empty graphics window that is otherwise present following startup.)

grDevices::palette(c(
  "#2e3436"   # (Aluminium 6)
  , "#ef2929" # (Scarlet Red 1)
  , "#73d216" # (Chameleon 2)
  , "#3465a4" # (Sky Blue 2)
  , "#fcaf3e" # (Orange 1)
  , "#ad7fa8" # (Plum 1)
  , "#babdb6" # (Butter 1)
  , "#babdb6" # (Aluminium 3)
))

grDevices::dev.off()